qid int64 4 8.14M | question stringlengths 20 48.3k | answers list | date stringlengths 10 10 | metadata list | input stringlengths 12 45k | output stringlengths 2 31.8k |
|---|---|---|---|---|---|---|
31,461 | <p>I know how to write querry args for WP_Query if it's a single key :
for example, if query posts with the metakey of 'type'--</p>
<pre><code>$query_args['type'] = (array)$type;
</code></pre>
<p>Now, the problem is-- the item I want to querry is saved inside an array, this array is saved as a postmeta.
This is my ar... | [
{
"answer_id": 31456,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 0,
"selected": false,
"text": "<p>Well there is no native \"portfolio\" shortcode, so your talking about a theme or plugin that is enabling that.</p>... | 2011/10/19 | [
"https://wordpress.stackexchange.com/questions/31461",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5210/"
] | I know how to write querry args for WP\_Query if it's a single key :
for example, if query posts with the metakey of 'type'--
```
$query_args['type'] = (array)$type;
```
Now, the problem is-- the item I want to querry is saved inside an array, this array is saved as a postmeta.
This is my array:
```
$details = arra... | Yes it is. Check this function (`has_shortcode`):
>
> ### [Check for a shortcode in a page/post content](http://wp.tutsplus.com/articles/quick-tip-improving-shortcodes-with-the-has_shortcode-function/)
>
>
> One of the mistakes that many developers make when creating shortcodes (in themes and plugins) is always loa... |
31,471 | <p>How to create new role with same capabilities of existing role.
Eg: I would like to create a new role with same capabilities of administrator or editor and so on..</p>
| [
{
"answer_id": 31472,
"author": "Rutwick Gangurde",
"author_id": 4740,
"author_profile": "https://wordpress.stackexchange.com/users/4740",
"pm_score": 6,
"selected": true,
"text": "<p>Try this... This should work.</p>\n\n<pre><code><?php\nadd_action('init', 'cloneRole');\n\nfunction c... | 2011/10/19 | [
"https://wordpress.stackexchange.com/questions/31471",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/680/"
] | How to create new role with same capabilities of existing role.
Eg: I would like to create a new role with same capabilities of administrator or editor and so on.. | Try this... This should work.
```
<?php
add_action('init', 'cloneRole');
function cloneRole()
{
global $wp_roles;
if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
$adm = $wp_roles->get_role('administrator');
//Adding a 'new_role' with all admin caps
$wp_roles->add_role('new_role', ... |
31,484 | <p>I have <a href="http://wordpress.site5.net/boldy/doc/" rel="nofollow">Boldy</a> theme on a 3.2.1 instance of Wordpress.</p>
<p>I have installed the plugin <a href="http://wordpress.org/extend/plugins/wp-postratings/installation/" rel="nofollow">WP-PostRatings</a>.</p>
<p>I want it to show up on my individual posts... | [
{
"answer_id": 31472,
"author": "Rutwick Gangurde",
"author_id": 4740,
"author_profile": "https://wordpress.stackexchange.com/users/4740",
"pm_score": 6,
"selected": true,
"text": "<p>Try this... This should work.</p>\n\n<pre><code><?php\nadd_action('init', 'cloneRole');\n\nfunction c... | 2011/10/19 | [
"https://wordpress.stackexchange.com/questions/31484",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4280/"
] | I have [Boldy](http://wordpress.site5.net/boldy/doc/) theme on a 3.2.1 instance of Wordpress.
I have installed the plugin [WP-PostRatings](http://wordpress.org/extend/plugins/wp-postratings/installation/).
I want it to show up on my individual posts when posts are viewed individually on a page.
* I installed and act... | Try this... This should work.
```
<?php
add_action('init', 'cloneRole');
function cloneRole()
{
global $wp_roles;
if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
$adm = $wp_roles->get_role('administrator');
//Adding a 'new_role' with all admin caps
$wp_roles->add_role('new_role', ... |
31,488 | <p>I'm almost complete whit my wp theme an I'm now translating it with the WPML plugin. This is working out great (even all my custom post types and meta boxes :) ), but of course there have to be a problem.
I have added meta boxes to one specific page and have target it like this: </p>
<pre><code>add_action('admin_i... | [
{
"answer_id": 31511,
"author": "Jonathan Liuti",
"author_id": 9531,
"author_profile": "https://wordpress.stackexchange.com/users/9531",
"pm_score": 1,
"selected": false,
"text": "<p>Use the <a href=\"http://wpml.org/documentation/support/creating-multilingual-wordpress-themes/language-d... | 2011/10/19 | [
"https://wordpress.stackexchange.com/questions/31488",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9563/"
] | I'm almost complete whit my wp theme an I'm now translating it with the WPML plugin. This is working out great (even all my custom post types and meta boxes :) ), but of course there have to be a problem.
I have added meta boxes to one specific page and have target it like this:
```
add_action('admin_init','my_meta_... | I've got this working finally ($template\_file == 'page-tjenester.php'), so now my meta boxes shows up only when I use this specific page-template!
This is the final code if someone is interesting;
```
add_action('admin_init','my_meta_init');
function my_meta_init()
{
$post_id = $_GET['post'] ? $_GET['post'] : $_POS... |
31,491 | <p>Hi I'm learning theming options based on the existing theme TwentyEleven.</p>
<p>I've come across the following code in inc/theme-options.php</p>
<pre><code>return apply_filters( 'twentyeleven_default_theme_options', $default_theme_options );
</code></pre>
<p>I can't seem to find the add_filter for 'twentyeleven_... | [
{
"answer_id": 31499,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": true,
"text": "<p>I don't believe there <em>is</em> an <code>add_filter()</code> call anywhere. If you want to override the op... | 2011/10/19 | [
"https://wordpress.stackexchange.com/questions/31491",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9215/"
] | Hi I'm learning theming options based on the existing theme TwentyEleven.
I've come across the following code in inc/theme-options.php
```
return apply_filters( 'twentyeleven_default_theme_options', $default_theme_options );
```
I can't seem to find the add\_filter for 'twentyeleven\_default\_theme\_options', or do... | I don't believe there *is* an `add_filter()` call anywhere. If you want to override the option defaults, you can call your own `add_filter()` to do so, either in a Plugin or in a Child Theme.
**EDIT**
An `apply_filters()` call is nothing more than a *filter hook definition*: basically, it is defining the data to whic... |
31,512 | <p>I have a custom post type of portfolio (slug portfolio) in my theme and all is working well except one thing. When people create a page with a slug of portfolio, eg: example.com/portfolio, the theme thinks I'm wanting to use the custom post type archive page, not my page created in the editor.</p>
<p>Can I somehow ... | [
{
"answer_id": 44891,
"author": "Max Yudin",
"author_id": 11761,
"author_profile": "https://wordpress.stackexchange.com/users/11761",
"pm_score": 1,
"selected": false,
"text": "<p>Create a page with a slug of 'portfolio' and make it 'Private'. It will be hidden from public when reserving... | 2011/10/19 | [
"https://wordpress.stackexchange.com/questions/31512",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9569/"
] | I have a custom post type of portfolio (slug portfolio) in my theme and all is working well except one thing. When people create a page with a slug of portfolio, eg: example.com/portfolio, the theme thinks I'm wanting to use the custom post type archive page, not my page created in the editor.
Can I somehow "reserve" ... | The following 2 filters allow you to hook into when WordPress checks the slug and are found in the function wp\_unique\_post\_slug() in the wp-includes/post.php file.
There are 2 filters, one for hierarchical posts and one for non-hierarchical. The hierarchical filter provides the ID for the post parent so if the $pos... |
31,521 | <p>I've read this on codex and seem some themes use it but never understood how it worked.</p>
<blockquote>
<p><code>(string) $hookname</code> used internally to track menu page callbacks for outputting the page inside the <code>global $menu</code> array</p>
</blockquote>
<p>I can't seem to understand the codex's e... | [
{
"answer_id": 44891,
"author": "Max Yudin",
"author_id": 11761,
"author_profile": "https://wordpress.stackexchange.com/users/11761",
"pm_score": 1,
"selected": false,
"text": "<p>Create a page with a slug of 'portfolio' and make it 'Private'. It will be hidden from public when reserving... | 2011/10/19 | [
"https://wordpress.stackexchange.com/questions/31521",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9215/"
] | I've read this on codex and seem some themes use it but never understood how it worked.
>
> `(string) $hookname` used internally to track menu page callbacks for outputting the page inside the `global $menu` array
>
>
>
I can't seem to understand the codex's explanation. Can some one enlighten me on how can we us... | The following 2 filters allow you to hook into when WordPress checks the slug and are found in the function wp\_unique\_post\_slug() in the wp-includes/post.php file.
There are 2 filters, one for hierarchical posts and one for non-hierarchical. The hierarchical filter provides the ID for the post parent so if the $pos... |
31,524 | <p>I see that there are a lot of similar questions here at WPSE, and I've tried many of the suggestions mentioned trying to solve my problem but with no success.</p>
<p>I have a category called News. In this category I want to run a custom query using WP Query to fetch and display articles, spread out through multiple... | [
{
"answer_id": 31532,
"author": "Paul",
"author_id": 9485,
"author_profile": "https://wordpress.stackexchange.com/users/9485",
"pm_score": 2,
"selected": true,
"text": "<p>This could be a plugin compatibility problem. Have you tried to disable all plugins and see if that solves the probl... | 2011/10/19 | [
"https://wordpress.stackexchange.com/questions/31524",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3390/"
] | I see that there are a lot of similar questions here at WPSE, and I've tried many of the suggestions mentioned trying to solve my problem but with no success.
I have a category called News. In this category I want to run a custom query using WP Query to fetch and display articles, spread out through multiple pages usi... | This could be a plugin compatibility problem. Have you tried to disable all plugins and see if that solves the problem?
I found this which may also be of help:
<http://dre.im/if-pages-return-a-404-after-wordpress-3-1-upgrade/>
1. Log in to wp-admin and go to permalinks, click save (this should refresh your permalink... |
31,533 | <p>Trying to set a 'removed' date time in a plugin query but I'm not sure how to use UPDATE SET with $wpdb->prepare.</p>
<p>Here's my query:</p>
<pre><code>$cur_date = date('Y-m-d G:i:s');
$rows_affected = $wpdb->query(
$wpdb->prepare("
UPDATE $table
SET ( removed, post_id, use... | [
{
"answer_id": 31542,
"author": "EarnestoDev",
"author_id": 8211,
"author_profile": "https://wordpress.stackexchange.com/users/8211",
"pm_score": 4,
"selected": true,
"text": "<p>I sort of fixed your query. It needs a table and a WHERE condition to prevent changing all rows. Even a LIMIT... | 2011/10/19 | [
"https://wordpress.stackexchange.com/questions/31533",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5391/"
] | Trying to set a 'removed' date time in a plugin query but I'm not sure how to use UPDATE SET with $wpdb->prepare.
Here's my query:
```
$cur_date = date('Y-m-d G:i:s');
$rows_affected = $wpdb->query(
$wpdb->prepare("
UPDATE $table
SET ( removed, post_id, user_id, status )
VALUES ( %... | I sort of fixed your query. It needs a table and a WHERE condition to prevent changing all rows. Even a LIMIT 1 at the end won't hurt.
```
$rows_affected = $wpdb->query(
$wpdb->prepare(
"UPDATE {$table} SET removed = %s, post_id = %d, user_id = %d, status = %d;",
$cur_date = date('Y-m-d H:i:s'), $p... |
31,545 | <p>I have a custom post type called portfolio. I need a previous/next link WITHOUT a plugin. Anybody have a solution?</p>
<p>Example post:
<a href="http://themeforward.com/demo2/archives/portfolio/boat">http://themeforward.com/demo2/archives/portfolio/boat</a></p>
<pre><code><?php get_header(); ?>
<!-- Be... | [
{
"answer_id": 31547,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 5,
"selected": true,
"text": "<p>If you need next/previous links for single posts, there is the built in <a href=\"http://codex.wordpress.o... | 2011/10/19 | [
"https://wordpress.stackexchange.com/questions/31545",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | I have a custom post type called portfolio. I need a previous/next link WITHOUT a plugin. Anybody have a solution?
Example post:
<http://themeforward.com/demo2/archives/portfolio/boat>
```
<?php get_header(); ?>
<!-- Begin wrap -->
<div class="clear">
<div id="full_container">
<div id="content2">
<div id="content">
... | If you need next/previous links for single posts, there is the built in [`next_post_link`](http://codex.wordpress.org/Function_Reference/next_post_link) function and matching [`previous_post_link`](http://codex.wordpress.org/Function_Reference/previous_post_link), both of which should probably be used within the loop.
... |
31,551 | <p>Since Wp 3.2 a lot of changed to TinyMCE and Wordpress and ow I can not find out how to add the Tiny MCE to meta box in Page.</p>
<p>This is how it looks when I am not firing up the MCE
<a href="http://screencast.com/t/ECQeyvJYC" rel="nofollow">http://screencast.com/t/ECQeyvJYC</a></p>
<p>And this is when I fire ... | [
{
"answer_id": 31569,
"author": "Arvind07",
"author_id": 4292,
"author_profile": "https://wordpress.stackexchange.com/users/4292",
"pm_score": -1,
"selected": false,
"text": "<pre>\nTo add TinyMCE editor please follow below given steps:\n\n 1. Add following function to your plugins file ... | 2011/10/19 | [
"https://wordpress.stackexchange.com/questions/31551",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5878/"
] | Since Wp 3.2 a lot of changed to TinyMCE and Wordpress and ow I can not find out how to add the Tiny MCE to meta box in Page.
This is how it looks when I am not firing up the MCE
<http://screencast.com/t/ECQeyvJYC>
And this is when I fire up the Tiny MCE
```
if ( typeof( tinyMCE ) == "object" && typeof( tinyMCE.exe... | Not sure if this helps but 3.3 introduced [wp\_editor()](http://codex.wordpress.org/Function_Reference/wp_editor) for displaying editors. |
31,554 | <p>So, According to the WordPress theme download page; the theme 'Twenty Ten' and it's child theme/plugin 'Responsive Twenty Ten' are compatible with 2.8+ </p>
<p><em>I'm stuck with using 2.8.5 at work, I don't have an answer to why - but am.</em> </p>
<p>I've uploaded both the plugin and the base theme manually - an... | [
{
"answer_id": 31561,
"author": "Niels",
"author_id": 6068,
"author_profile": "https://wordpress.stackexchange.com/users/6068",
"pm_score": 2,
"selected": false,
"text": "<p>There's a plugin for that :-)</p>\n\n<p><a href=\"http://wordpress.org/extend/plugins/hide-categories/\" rel=\"nof... | 2011/10/19 | [
"https://wordpress.stackexchange.com/questions/31554",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9594/"
] | So, According to the WordPress theme download page; the theme 'Twenty Ten' and it's child theme/plugin 'Responsive Twenty Ten' are compatible with 2.8+
*I'm stuck with using 2.8.5 at work, I don't have an answer to why - but am.*
I've uploaded both the plugin and the base theme manually - and was stoked to begin im... | There's a plugin for that :-)
<http://wordpress.org/extend/plugins/hide-categories/> |
31,556 | <p>For a WordPress site I am working on, there is a jquery slider (based on the coda slider) where videos are presented.
All of the videos are from Vimeo.
If a video is playing and someone slides to the next video, the other video continues to play.
I have found some API code from Vimeo that allows me to control the v... | [
{
"answer_id": 31643,
"author": "endle.winters",
"author_id": 9355,
"author_profile": "https://wordpress.stackexchange.com/users/9355",
"pm_score": 1,
"selected": false,
"text": "<p>Okay, by much digging around I was able to find a patch someone had created for the class-oembed.php file ... | 2011/10/19 | [
"https://wordpress.stackexchange.com/questions/31556",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9355/"
] | For a WordPress site I am working on, there is a jquery slider (based on the coda slider) where videos are presented.
All of the videos are from Vimeo.
If a video is playing and someone slides to the next video, the other video continues to play.
I have found some API code from Vimeo that allows me to control the vide... | I add a frame ID using an each function's index, and then appending the src with the string you need:
```
jQuery('#video-gallery-list li.video-player').each(function(i) {
// set up a variable for the src that includes the new unique ID you're about to use
var this_src = jQuery(this).find('iframe').attr('src') ... |
31,563 | <p>I need to be able to tell if an admin is logged in ouside of the loop.</p>
<p>This is needed for some php files that are part of a WP site but do not use <code>require( '../wp-load.php );</code></p>
<p>What I need to do is keep the Google Analytics tracker JS from firing for logged in admins, but track everyone el... | [
{
"answer_id": 31566,
"author": "EarnestoDev",
"author_id": 8211,
"author_profile": "https://wordpress.stackexchange.com/users/8211",
"pm_score": 0,
"selected": false,
"text": "<p>Either use <strong>wp-load.php</strong> <em>(performance taxing)</em> or do the following:</p>\n\n<pre><code... | 2011/10/20 | [
"https://wordpress.stackexchange.com/questions/31563",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/268/"
] | I need to be able to tell if an admin is logged in ouside of the loop.
This is needed for some php files that are part of a WP site but do not use `require( '../wp-load.php );`
What I need to do is keep the Google Analytics tracker JS from firing for logged in admins, but track everyone else.
How do I find out if an... | You can use current\_user\_can() to determine if an admin user is logged and load your Google tracking code using wp\_enqueue\_script with an if statement in functions.php
```
if ( ! current_user_can( 'edit_posts' ) ) {
wp_enqueue_script( 'google-tracking');
}
``` |
31,573 | <p>i built a custom wordpress theme, and for some reason don't know why the posts/pages are not showing up in the theme, but they show up in all other themes. Here is the index.php code:</p>
<pre><code><?php get_header( ); ?>
<div id = "contentwrapper">
<div id = "content" role = "main">
... | [
{
"answer_id": 31585,
"author": "Alex Sancho",
"author_id": 2536,
"author_profile": "https://wordpress.stackexchange.com/users/2536",
"pm_score": 1,
"selected": false,
"text": "<p>Try this basic template layout </p>\n\n<pre><code><?php\n get_header(); # ge... | 2011/10/20 | [
"https://wordpress.stackexchange.com/questions/31573",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9390/"
] | i built a custom wordpress theme, and for some reason don't know why the posts/pages are not showing up in the theme, but they show up in all other themes. Here is the index.php code:
```
<?php get_header( ); ?>
<div id = "contentwrapper">
<div id = "content" role = "main">
<div id = "leftcolumn">
... | Try this basic template layout
```
<?php
get_header(); # gets header.php contents
if (have_posts()): # checks if there are any post available for this url
while(have_posts()): # starts loop
the_post(); # ass... |
31,576 | <p>why my sql statement is not returning any value.. is this wrong?</p>
<pre><code><?php
global $wpdb;
$result = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->wp_frm_item_metas"));
foreach ($result as $item){
$eventname= $result->meta_value;
}
... | [
{
"answer_id": 31580,
"author": "Joiwoo",
"author_id": 9157,
"author_profile": "https://wordpress.stackexchange.com/users/9157",
"pm_score": 3,
"selected": true,
"text": "<p>I believe for your foreach function should be like below:</p>\n\n<pre><code>foreach ($result as $item){\n ... | 2011/10/20 | [
"https://wordpress.stackexchange.com/questions/31576",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9583/"
] | why my sql statement is not returning any value.. is this wrong?
```
<?php
global $wpdb;
$result = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->wp_frm_item_metas"));
foreach ($result as $item){
$eventname= $result->meta_value;
}
?>
<h2><?php ech... | I believe for your foreach function should be like below:
```
foreach ($result as $item){
$eventname= $item->meta_value;
}
``` |
31,607 | <p>I need to disable drag&drop functionality for dashboard widgets.</p>
<p>This should be realized with jquery, just as it is for the dashboard_browser_nag. I'm no jquery expert - so can anybody tell me how to find and modify my widgets with jquery?</p>
<p>So far, I know that I have to do some .sortable("cancel")... | [
{
"answer_id": 31644,
"author": "kingkool68",
"author_id": 2744,
"author_profile": "https://wordpress.stackexchange.com/users/2744",
"pm_score": 0,
"selected": false,
"text": "<p>Not tested, but this would atleast get you started. Add this to functions.php or make your own plugin for it.... | 2011/10/20 | [
"https://wordpress.stackexchange.com/questions/31607",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9595/"
] | I need to disable drag&drop functionality for dashboard widgets.
This should be realized with jquery, just as it is for the dashboard\_browser\_nag. I'm no jquery expert - so can anybody tell me how to find and modify my widgets with jquery?
So far, I know that I have to do some .sortable("cancel"), but how exactly?
... | This will remove the draggable functionality from each widget:
```
jQuery('.widget.ui-draggable').draggable('destroy')
```
You have find a good way to inject this into your code, either through `wp_enqueue_script()` or echo it inline on the Widget page.
To target a specific Widget you would have to do something alo... |
31,627 | <p>Trying to replicate some functionality I've seen on a few other themes before, but would like to know/understand for my own uses.</p>
<p>I've created a custom post type, called "testimonials". I believe I've knocked out a pretty good chunk of the setup, using <a href="http://justintadlock.com/archives/2010/04/29/cu... | [
{
"answer_id": 31632,
"author": "Rutwick Gangurde",
"author_id": 4740,
"author_profile": "https://wordpress.stackexchange.com/users/4740",
"pm_score": 4,
"selected": true,
"text": "<p>There is a filter <code>get_sample_permalink_html</code> that returns this area as a string. Here's how ... | 2011/10/20 | [
"https://wordpress.stackexchange.com/questions/31627",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9605/"
] | Trying to replicate some functionality I've seen on a few other themes before, but would like to know/understand for my own uses.
I've created a custom post type, called "testimonials". I believe I've knocked out a pretty good chunk of the setup, using [Justin Tadlock's awesome post on Custom Post Types](http://justin... | There is a filter `get_sample_permalink_html` that returns this area as a string. Here's how you can use it:
```
<?php
add_filter('get_sample_permalink_html', 'perm', '',4);
function perm($return, $id, $new_title, $new_slug){
global $post;
if($post->post_type == 'testimonials')
{
... |
31,629 | <p>I'm currently using the menu_order field in the DB to have some custom ordering of posts. I want to expose this field to the user via the admin section, like it is when editing a Page (in Page Attributes).</p>
<p>Is there a simple way to do this?</p>
| [
{
"answer_id": 31630,
"author": "Drew Gourley",
"author_id": 4282,
"author_profile": "https://wordpress.stackexchange.com/users/4282",
"pm_score": 0,
"selected": false,
"text": "<p>This isn't the exact interface you're asking for, but you might like this.</p>\n\n<p><a href=\"http://drewg... | 2011/10/20 | [
"https://wordpress.stackexchange.com/questions/31629",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9578/"
] | I'm currently using the menu\_order field in the DB to have some custom ordering of posts. I want to expose this field to the user via the admin section, like it is when editing a Page (in Page Attributes).
Is there a simple way to do this? | ```
<?php
add_action( 'init', 'wpse31629_init' );
function wpse31629_init()
{
add_post_type_support( 'post', 'page-attributes' );
}
```
Add that to your `functions.php` or in a [plugin file](https://gist.github.com/1301501) and you'll get an attributes dialog box with the menu order input. |
31,646 | <p>how do I get names of child categories of an arbitrary Post? </p>
<p>For example i got category slug - 'motorbikes' and I got subcategories for it. So I need to get each posts subcategory name thats inside category with slug motorbikes.
Y2ok</p>
| [
{
"answer_id": 31649,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 5,
"selected": true,
"text": "<p>To get the child categories of a given parent category slug, use a combination of <a href=\"http://codex.wor... | 2011/10/20 | [
"https://wordpress.stackexchange.com/questions/31646",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9607/"
] | how do I get names of child categories of an arbitrary Post?
For example i got category slug - 'motorbikes' and I got subcategories for it. So I need to get each posts subcategory name thats inside category with slug motorbikes.
Y2ok | To get the child categories of a given parent category slug, use a combination of [`get_category_by_slug()`](http://codex.wordpress.org/Function_Reference/get_category_by_slug) and [`get_categories()`](http://codex.wordpress.org/Function_Reference/get_categories).
The latter function will return an array of category o... |
31,647 | <p>I found this problem on Wordpress Support and the topic unfortunately is now closed. I have this same issue... (read below)</p>
<hr>
<p>We have created a site where members can recommend things like favourite books, movie, songs, etc. For this problem I will use the Movies page as an example.</p>
<p>The "Movies"... | [
{
"answer_id": 33275,
"author": "Nick Ryall",
"author_id": 10132,
"author_profile": "https://wordpress.stackexchange.com/users/10132",
"pm_score": 5,
"selected": false,
"text": "<p>You can use a filter to modify the ORDER BY statement of WP_query. </p>\n\n<p>That way you can manually set... | 2011/10/20 | [
"https://wordpress.stackexchange.com/questions/31647",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9604/"
] | I found this problem on Wordpress Support and the topic unfortunately is now closed. I have this same issue... (read below)
---
We have created a site where members can recommend things like favourite books, movie, songs, etc. For this problem I will use the Movies page as an example.
The "Movies" page is ultimately... | You can use a filter to modify the ORDER BY statement of WP\_query.
That way you can manually set the query to use ORDER BY RAND($seed);
Mysql RAND() accepts a seed as an optional argument. Using a seed, it will return the same randomized result set each time.
So you can generate a random number on the first page l... |
31,678 | <p>I'm trying to implement a "publish" button from a custom post type metabox. Everything actually works fine if I either create a new button and manually call submit() or duplicate the regular submit buttons, except for one thing: if i change the title of the post, I always get the "Confirm Navigation" popup asking ... | [
{
"answer_id": 49895,
"author": "Kevin",
"author_id": 15448,
"author_profile": "https://wordpress.stackexchange.com/users/15448",
"pm_score": 3,
"selected": true,
"text": "<p>You can stimulate click to Update post button like this..\n<a href=\"https://wordpress.stackexchange.com/question... | 2011/10/21 | [
"https://wordpress.stackexchange.com/questions/31678",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9253/"
] | I'm trying to implement a "publish" button from a custom post type metabox. Everything actually works fine if I either create a new button and manually call submit() or duplicate the regular submit buttons, except for one thing: if i change the title of the post, I always get the "Confirm Navigation" popup asking me if... | You can stimulate click to Update post button like this..
[Adding submit or update button to custom metabox?](https://wordpress.stackexchange.com/questions/32380/adding-submit-or-update-button-to-custom-metabox)
```
<script>
jQuery('.metabox_submit').click(function(e) {
e.preventDefault();
jQuery('#publish').c... |
31,694 | <p>When I post something on Wordpress, it's posted with my display name. However if I change my display name, posts posted by me will be updated with the new author. Comments will stay with the old name. </p>
<p>Since in my wordpress site comments are available only for registered users, and the display name field is... | [
{
"answer_id": 31697,
"author": "soulseekah",
"author_id": 9480,
"author_profile": "https://wordpress.stackexchange.com/users/9480",
"pm_score": 0,
"selected": false,
"text": "<p>You have to remember that each profile sets his/her own <code>display_name</code> setting, and in order to en... | 2011/10/21 | [
"https://wordpress.stackexchange.com/questions/31694",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8294/"
] | When I post something on Wordpress, it's posted with my display name. However if I change my display name, posts posted by me will be updated with the new author. Comments will stay with the old name.
Since in my wordpress site comments are available only for registered users, and the display name field is hidden - t... | This code does the job with a filter. Doesn't care what the comment says the author's name is.
Nothing particularly tricky about it. Should be self-explanatory.
```
add_filter('get_comment_author', 'wpse31694_comment_author_display_name');
function wpse31694_comment_author_display_name($author) {
global $comment... |
31,698 | <p>I need to allow post ordering in certain categories. One of the sorting options is a custom field meta value.
First problem is that not all posts have that meta assigned and i need to order these by date (default). </p>
<p>Another problem is that meta field should use ASC order and the rest DESC.</p>
<p>My code so... | [
{
"answer_id": 31708,
"author": "EarnestoDev",
"author_id": 8211,
"author_profile": "https://wordpress.stackexchange.com/users/8211",
"pm_score": 2,
"selected": false,
"text": "<p>Assuming the rest works, why not order the <em>normal way</em>:</p>\n\n<pre><code>function sort_posts_orderb... | 2011/10/21 | [
"https://wordpress.stackexchange.com/questions/31698",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4192/"
] | I need to allow post ordering in certain categories. One of the sorting options is a custom field meta value.
First problem is that not all posts have that meta assigned and i need to order these by date (default).
Another problem is that meta field should use ASC order and the rest DESC.
My code so far
In Template... | Assuming the rest works, why not order the *normal way*:
```
function sort_posts_orderby( $orderby ) {
$orderby = 'wp_postmeta.meta_value ASC, wp_posts.post_date DESC';
return $orderby;
}
``` |
31,700 | <p>I need to block access to all other content except Index,wp-login.php, register.php till the user login. how to accomplish it.</p>
<p>i created everthing but, when i try <strong>mysite.com/members</strong> it shows the page how to disable it..</p>
| [
{
"answer_id": 31704,
"author": "soulseekah",
"author_id": 9480,
"author_profile": "https://wordpress.stackexchange.com/users/9480",
"pm_score": 1,
"selected": false,
"text": "<p><code>/members</code> shows because it's rewritten to <code>index.php?pagename=members</code> or <code>index.... | 2011/10/21 | [
"https://wordpress.stackexchange.com/questions/31700",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7376/"
] | I need to block access to all other content except Index,wp-login.php, register.php till the user login. how to accomplish it.
i created everthing but, when i try **mysite.com/members** it shows the page how to disable it.. | Functional code written using **PHP 5.3+ Closures**. Read the comments throughout to understand concept and flow.
```
// Hook right before Themes kick in
add_action('wp', function(){
// Allow viewing of home/front_page
if(is_home() or is_front_page()) return;
// Maybe allow access to archives (non singular... |
31,701 | <p>I found a script so I can take care that on some months I can change the number of post at a page.</p>
<p>So I implment this script at this way : <a href="http://pastebin.com/Nbqy0KBU" rel="nofollow">http://pastebin.com/Nbqy0KBU</a></p>
<p>But still all articles are displayed as you can see here : <a href="http://... | [
{
"answer_id": 31702,
"author": "Taylor Dewey",
"author_id": 3832,
"author_profile": "https://wordpress.stackexchange.com/users/3832",
"pm_score": 1,
"selected": false,
"text": "<p><code>is_category();</code> is checking if you're on a category archive or not. So, <code>is_category('1per... | 2011/10/21 | [
"https://wordpress.stackexchange.com/questions/31701",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9629/"
] | I found a script so I can take care that on some months I can change the number of post at a page.
So I implment this script at this way : <http://pastebin.com/Nbqy0KBU>
But still all articles are displayed as you can see here : <http://test.tamarawobben.nl/2005/04>
Anyone a idea why and how to solve this ?
Roelof
... | Consider this option of achieving what you seem to be requiring:
```
function wpse31701_filter_query() {
global $wp_query;
// Check year and month
if ( $wp_query->get( 'year' ) == 2005 and $wp_query->get( 'monthnum' ) == 5 )
// Check page number to apply offset
if ( $wp_query->get( 'paged')... |
31,711 | <p>I added the following code to my functions.php file to create a custom post type.</p>
<pre><code> function create_post_type() {
register_post_type( 'mysite_reviews',
array(
'labels' => array(
'name' => __( 'Reviews' ),
'singular_name' =>... | [
{
"answer_id": 31712,
"author": "EarnestoDev",
"author_id": 8211,
"author_profile": "https://wordpress.stackexchange.com/users/8211",
"pm_score": 0,
"selected": false,
"text": "<p>Not really sure what you want to achieve from your description but, if you want a custom post type in the lo... | 2011/10/21 | [
"https://wordpress.stackexchange.com/questions/31711",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7298/"
] | I added the following code to my functions.php file to create a custom post type.
```
function create_post_type() {
register_post_type( 'mysite_reviews',
array(
'labels' => array(
'name' => __( 'Reviews' ),
'singular_name' => __( 'Review' )
... | `flush_rewrite_rules()` as soon as you register the custom post type. It appears that they have not been rewritten yet, that is, most probably, why you're getting an embarrassing message.
```
register_post_type( 'mysite_reviews',
array(
'labels' => array(
'name' => __( 'Reviews'... |
31,725 | <p>I was thinking about a nicer way to display the categories in my sidebar.
Instead of a plain list style, I'd like to have images / thumbnails show up as well.</p>
<p>Currently I'm using the following:</p>
<pre><code><?php wp_list_categories('show_last_updated=1&show_count=1&title_li='); ?>
</code></... | [
{
"answer_id": 31743,
"author": "soulseekah",
"author_id": 9480,
"author_profile": "https://wordpress.stackexchange.com/users/9480",
"pm_score": 2,
"selected": true,
"text": "<p>You can use a custom <a href=\"http://codex.wordpress.org/Function_Reference/Walker_Class\" rel=\"nofollow\">W... | 2011/10/21 | [
"https://wordpress.stackexchange.com/questions/31725",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6903/"
] | I was thinking about a nicer way to display the categories in my sidebar.
Instead of a plain list style, I'd like to have images / thumbnails show up as well.
Currently I'm using the following:
```
<?php wp_list_categories('show_last_updated=1&show_count=1&title_li='); ?>
```
Simply displaying the name/link + post... | You can use a custom [Walker](http://codex.wordpress.org/Function_Reference/Walker_Class), the easiest of which in your case is the `Walker_Category` and extend it like so:
```
class CategoryThumbnail_Walker extends Walker_Category {
// A new element has been stumbled upon and has ended
function end_el( &$outp... |
31,726 | <p>I'm developing a couple of open-source plugins and a theme (all part of a "suite") that all use the same third party PHP library. I'm wondering what is the best way to include it in Wordpress. Here are some thoughts:</p>
<ul>
<li>put it in one of the plugins and require that plugin to be installed and activated</li... | [
{
"answer_id": 31729,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 4,
"selected": true,
"text": "<p>If each plugin/theme functions on its own, then you should probably drop the the library in every theme/pl... | 2011/10/21 | [
"https://wordpress.stackexchange.com/questions/31726",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9631/"
] | I'm developing a couple of open-source plugins and a theme (all part of a "suite") that all use the same third party PHP library. I'm wondering what is the best way to include it in Wordpress. Here are some thoughts:
* put it in one of the plugins and require that plugin to be installed and activated
* create a specia... | If each plugin/theme functions on its own, then you should probably drop the the library in every theme/plugin.
Then just check to see if it a class or function from the third-party library exists before requiring it.
```
<?php
if( class_exists( 'SomeClass' ) )
{
// require/include here
}
```
or
```
<?php
if( ... |
31,727 | <p>Currently the search results are all shown in the same way, no matter if it's a post or a static page.
As I don't want the comment count and the categories to show up for static pages, I was wondering how to do it.</p>
<p>The code: <strong>(Update October 22nd)</strong></p>
<pre><code><?php
if(get_post_type... | [
{
"answer_id": 31744,
"author": "saq",
"author_id": 9590,
"author_profile": "https://wordpress.stackexchange.com/users/9590",
"pm_score": 1,
"selected": false,
"text": "<pre><code>if (is_page('your_static_page_slug'))\n</code></pre>\n"
},
{
"answer_id": 31807,
"author": "Earn... | 2011/10/21 | [
"https://wordpress.stackexchange.com/questions/31727",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6903/"
] | Currently the search results are all shown in the same way, no matter if it's a post or a static page.
As I don't want the comment count and the categories to show up for static pages, I was wondering how to do it.
The code: **(Update October 22nd)**
```
<?php
if(get_post_type() == 'page') : ?>
<div class="rece... | ```
<?php if(get_post_type() == 'page'): // Only pages ?>
<div class="recent_postMetaSingle">
<img src="<?php bloginfo('template_directory'); ?>/images/eye.png" alt="Views" title="views" />
<?php print_page_views(get_the_ID('')); ?>
<p>This is a static page!</p></div>
<?php elseif(get_post_... |
31,738 | <h1>Multiple taxonomies in URL</h1>
<h3>How does one append multiple taxonomies to the URL having the following:</h3>
<blockquote>
<ul>
<li>Post Type: <strong>products</strong></li>
<li>Taxonomy: <strong>product_type</strong></li>
<li>Taxonomy: <strong>product_brand</strong></li>
</ul>
</blockquote>
<p><br... | [
{
"answer_id": 31746,
"author": "soulseekah",
"author_id": 9480,
"author_profile": "https://wordpress.stackexchange.com/users/9480",
"pm_score": 3,
"selected": false,
"text": "<p>This is certainly possible by utilizing some rewrite rules of your own to some extent. The <a href=\"http://c... | 2011/10/21 | [
"https://wordpress.stackexchange.com/questions/31738",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9635/"
] | Multiple taxonomies in URL
==========================
### How does one append multiple taxonomies to the URL having the following:
>
> * Post Type: **products**
> * Taxonomy: **product\_type**
> * Taxonomy: **product\_brand**
>
>
>
### Adding new product and selecting type and brand for this product:
When addin... | This is certainly possible by utilizing some rewrite rules of your own to some extent. The [WP\_Rewrite](http://codex.wordpress.org/Class_Reference/WP_Rewrite) API exposes functions that allow you to add rewrite rules (or 'maps') to convert a request to a query.
There are prerequisites to writing good rewrite rules, a... |
31,748 | <p>I tried looking for info about how to exclude/remove nav menu items from custom menus, and the only <a href="https://wordpress.stackexchange.com/questions/25284/how-can-i-remove-a-menu-item-programmatically">thread</a> I found did not have any answers that were useful to me.</p>
<p><strong>1. Background:</strong></... | [
{
"answer_id": 31753,
"author": "soulseekah",
"author_id": 9480,
"author_profile": "https://wordpress.stackexchange.com/users/9480",
"pm_score": 6,
"selected": true,
"text": "<h2>Method 1</h2>\n\n<p>You can add a constructor to your custom Walker to store some additional exclusion argume... | 2011/10/21 | [
"https://wordpress.stackexchange.com/questions/31748",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8621/"
] | I tried looking for info about how to exclude/remove nav menu items from custom menus, and the only [thread](https://wordpress.stackexchange.com/questions/25284/how-can-i-remove-a-menu-item-programmatically) I found did not have any answers that were useful to me.
**1. Background:**
I put together a Dock menu using W... | Method 1
--------
You can add a constructor to your custom Walker to store some additional exclusion arguments, like:
```
class custom_nav_walker extends Walker_Nav_Menu {
function __construct( $exclude = null ) {
$this->exclude = $exclude;
}
function skip( $item ) {
return in_array($item... |
31,752 | <p>At the moment my nav menu's category list only links to normal post_type archives. I'd like to dynamically append a custom post type, specifically ?post_type=portfolio, to the end of each url that particular drop down list. But I really don't know anything about php regex at the moment, except that I think that's wh... | [
{
"answer_id": 31753,
"author": "soulseekah",
"author_id": 9480,
"author_profile": "https://wordpress.stackexchange.com/users/9480",
"pm_score": 6,
"selected": true,
"text": "<h2>Method 1</h2>\n\n<p>You can add a constructor to your custom Walker to store some additional exclusion argume... | 2011/10/21 | [
"https://wordpress.stackexchange.com/questions/31752",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8482/"
] | At the moment my nav menu's category list only links to normal post\_type archives. I'd like to dynamically append a custom post type, specifically ?post\_type=portfolio, to the end of each url that particular drop down list. But I really don't know anything about php regex at the moment, except that I think that's wha... | Method 1
--------
You can add a constructor to your custom Walker to store some additional exclusion arguments, like:
```
class custom_nav_walker extends Walker_Nav_Menu {
function __construct( $exclude = null ) {
$this->exclude = $exclude;
}
function skip( $item ) {
return in_array($item... |
31,759 | <p>I have posts with a <code>custom field</code> called <code>year</code>. The year ranges from <code>1900 to 2011</code>. I want to create an individual page for each year which will displays the posts with that year. So I will be creating a page with a template and a custom query to find all posts with that specific ... | [
{
"answer_id": 31762,
"author": "EarnestoDev",
"author_id": 8211,
"author_profile": "https://wordpress.stackexchange.com/users/8211",
"pm_score": 0,
"selected": false,
"text": "<pre><code>global $post;\n// This is how you get the year of a post, not from the URL\n$post_year = idate('Y', ... | 2011/10/21 | [
"https://wordpress.stackexchange.com/questions/31759",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9511/"
] | I have posts with a `custom field` called `year`. The year ranges from `1900 to 2011`. I want to create an individual page for each year which will displays the posts with that year. So I will be creating a page with a template and a custom query to find all posts with that specific year.
However, instead of creating ... | This problem can be solved with the [WordPress Rewrite API](http://codex.wordpress.org/Rewrite_API)
The simplest way
----------------
I assume that you've created a page called `year` and the request is most probably matched to this rule `(.+?)(/[0-9]+)?/?$`, with the query rewritten to `pagename=year`.
However, you... |
31,784 | <p>I have custom form for posting in my theme file. I also need to upload photos(videos also but photos are more important now) and I prepared form using wp handle upload function. It's working, images are uploading but they're not inserting into the post. Please help me. Here is a code full <a href="http://cdpst.net/s... | [
{
"answer_id": 31790,
"author": "soulseekah",
"author_id": 9480,
"author_profile": "https://wordpress.stackexchange.com/users/9480",
"pm_score": 0,
"selected": false,
"text": "<p>First of all it should be noted that your form does not appear to have the required <code>MAX_FILE_SIZE</code... | 2011/10/22 | [
"https://wordpress.stackexchange.com/questions/31784",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9649/"
] | I have custom form for posting in my theme file. I also need to upload photos(videos also but photos are more important now) and I prepared form using wp handle upload function. It's working, images are uploading but they're not inserting into the post. Please help me. Here is a code full <http://cdpst.net/s8i5jsfuf> a... | Let's presume your FILE variable is called 'files' and can contain multiple inputs (i.e. name="files[]")
1) First upload the files
```
$uploads = wp_upload_dir();
$upload_file_url = array();
foreach ($_FILES['files']['name'] as $key => $value_data)
{
$errors_founds = '';
if ($_FILES['files'][... |
31,785 | <p>I will have two admin users, one of them only speaking italian and the other only speaks english. How can I setup multi-language admin user interface? </p>
| [
{
"answer_id": 31789,
"author": "soulseekah",
"author_id": 9480,
"author_profile": "https://wordpress.stackexchange.com/users/9480",
"pm_score": 3,
"selected": true,
"text": "<p>There are a couple of methods that this can be done without the overhead of plugins.</p>\n\n<h2>Method 1</h2>\... | 2011/10/22 | [
"https://wordpress.stackexchange.com/questions/31785",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2867/"
] | I will have two admin users, one of them only speaking italian and the other only speaks english. How can I setup multi-language admin user interface? | There are a couple of methods that this can be done without the overhead of plugins.
Method 1
--------
The first method involves hooking to the `load_textdomain_mofile` filter.
(*This must go into a separate plugin*)
```
function wpse31785_change_mofile( $mofile, $domain ) {
if ( $domain == 'default'
an... |
31,791 | <p>I would like new users of the blog to have custom role, rather then Subscriber. How do I set this programmatically? I know that it can be changed from the backend.</p>
| [
{
"answer_id": 31792,
"author": "Delphi Electronice",
"author_id": 5708,
"author_profile": "https://wordpress.stackexchange.com/users/5708",
"pm_score": 3,
"selected": false,
"text": "<p>After you created the user using</p>\n\n<pre><code>$user_id = wp_create_user( $user_login, $pas1, $us... | 2011/10/22 | [
"https://wordpress.stackexchange.com/questions/31791",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/421/"
] | I would like new users of the blog to have custom role, rather then Subscriber. How do I set this programmatically? I know that it can be changed from the backend. | This allows plugins to easily hijack the default role while they're active.
```
// Hijack the option, the role will follow!
add_filter('pre_option_default_role', function($default_role){
// You can also add conditional tags here and return whatever
return 'subscriber'; // This is changed
return $default_ro... |
31,802 | <p>Can the wordpress theme folder be renamed any time freely and everything works fine after that ,</p>
<pre><code>themes/oldthemename
themes/whatevernewname
</code></pre>
<p>or is it so that if you change the folder name that contains theme files - then the theme wont work any more because theme folder name is relat... | [
{
"answer_id": 31804,
"author": "soulseekah",
"author_id": 9480,
"author_profile": "https://wordpress.stackexchange.com/users/9480",
"pm_score": 4,
"selected": false,
"text": "<p>This depends on how the theme was developed from the beginning. Theoretically, if everything was coded to sta... | 2011/10/22 | [
"https://wordpress.stackexchange.com/questions/31802",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7572/"
] | Can the wordpress theme folder be renamed any time freely and everything works fine after that ,
```
themes/oldthemename
themes/whatevernewname
```
or is it so that if you change the folder name that contains theme files - then the theme wont work any more because theme folder name is related to the theme files some... | This depends on how the theme was developed from the beginning. Theoretically, if everything was coded to standards you can rename the folder and nothing bad will happen.
When renaming the folder you are at risk of breaking code that asks specifically for files from the theme directory by name. WordPress offers a numb... |
31,809 | <p>How would I go about requiring each post to have no more than one tag?</p>
<p>I would like to require the user to create a tag or choose one previous tag for each post.
If you could give me any information, that would be very helpful.</p>
| [
{
"answer_id": 31810,
"author": "EarnestoDev",
"author_id": 8211,
"author_profile": "https://wordpress.stackexchange.com/users/8211",
"pm_score": 0,
"selected": false,
"text": "<p>Override the tag MetaBox and set only a text field that will be that single Tag. On updates, delete old tags... | 2011/10/22 | [
"https://wordpress.stackexchange.com/questions/31809",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9655/"
] | How would I go about requiring each post to have no more than one tag?
I would like to require the user to create a tag or choose one previous tag for each post.
If you could give me any information, that would be very helpful. | **Have fun.**
This works for any post type *(including customs)* that supports the 'post\_tag' taxonomy. 99.9% of the time, it will apply only to 'post' post type. *But we make compatible stuff ;)*
```
/*
Plugin Name: Single Postag
Description: Enforces use of single 'post_tag' taxonomy on select posts.
Author: Earne... |
31,811 | <p>Is there a filter for allowing HTML / Javascript into a custom field textarea? I'm using get_post_meta.</p>
<p>On the frontpage I want the HTML / Javascript to run, not to be displayed.</p>
| [
{
"answer_id": 31815,
"author": "EarnestoDev",
"author_id": 8211,
"author_profile": "https://wordpress.stackexchange.com/users/8211",
"pm_score": -1,
"selected": false,
"text": "<p><strong>Use the plugin I posted here:</strong>\n<a href=\"https://wordpress.stackexchange.com/questions/309... | 2011/10/22 | [
"https://wordpress.stackexchange.com/questions/31811",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5244/"
] | Is there a filter for allowing HTML / Javascript into a custom field textarea? I'm using get\_post\_meta.
On the frontpage I want the HTML / Javascript to run, not to be displayed. | The correct answer is `esc_textarea()`.
Example:
```
<textarea><?php echo esc_textarea($whatever); ?></textarea>
``` |
31,814 | <p>I'm need some help on my query. </p>
<p>I'm building up a category page where on top a post need to show where custom field key 'uitleg' has value 'ja'. Per category there is only one post with that value. I use this post as an introduction post. Below that post I need to show all other posts in the same category m... | [
{
"answer_id": 31835,
"author": "Brooke.",
"author_id": 2204,
"author_profile": "https://wordpress.stackexchange.com/users/2204",
"pm_score": 0,
"selected": false,
"text": "<p>You should be able to use the offset arg in your <a href=\"http://codex.wordpress.org/Template_Tags/get_posts\" ... | 2011/10/22 | [
"https://wordpress.stackexchange.com/questions/31814",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9442/"
] | I'm need some help on my query.
I'm building up a category page where on top a post need to show where custom field key 'uitleg' has value 'ja'. Per category there is only one post with that value. I use this post as an introduction post. Below that post I need to show all other posts in the same category minus the i... | You should take the condition outide the loop meaning above
```
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
```
Therewise every time the loop begins it start the check instead of doing the check then starting the loop if the condition exist.
Its hard for to understand because i dont understand ... |
31,867 | <p>I'm having a small issue with category pages for a custom taxonomy when custom permalinks are used, and I was wondering if someone might be able to help out and point out where I'm going wrong.</p>
<p>I've created a taxonomy "Brands" for use with a custom post type (in this case, Products), using the code below pla... | [
{
"answer_id": 31887,
"author": "xmarcos",
"author_id": 1061,
"author_profile": "https://wordpress.stackexchange.com/users/1061",
"pm_score": 2,
"selected": false,
"text": "<p>If you use a permalinkg structure with a front base, make sure <code>with_front</code> is <code>true</code>.</p>... | 2011/10/23 | [
"https://wordpress.stackexchange.com/questions/31867",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9675/"
] | I'm having a small issue with category pages for a custom taxonomy when custom permalinks are used, and I was wondering if someone might be able to help out and point out where I'm going wrong.
I've created a taxonomy "Brands" for use with a custom post type (in this case, Products), using the code below place in the ... | Add `flush_rewrite_rules();` after your register taxonomies. That fixed it for me.
**Edit**
Do make sure you do it on install of your plugin if you're using it on one. **It should only be run once on pug-in activation - and not on every page load**. Alternatively visit Settings > Permalinks page as this flushes the r... |
31,876 | <p>Because of the add_action I'm doing on get_content(), where I'm appending social media icons to the end of the post, it appears that calls to get_the_excerpt() are picking up the part of the javascript and appending it to the end of the text returned from get_the_excerpt(). I suppose this is caused by the fact that ... | [
{
"answer_id": 49843,
"author": "onetrickpony",
"author_id": 1986,
"author_profile": "https://wordpress.stackexchange.com/users/1986",
"pm_score": 1,
"selected": false,
"text": "<p>Read <a href=\"http://digitalnature.eu/blog/2011/09/12/how-to-correctly-hook-your-filter-to-the-post-conten... | 2011/10/23 | [
"https://wordpress.stackexchange.com/questions/31876",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6620/"
] | Because of the add\_action I'm doing on get\_content(), where I'm appending social media icons to the end of the post, it appears that calls to get\_the\_excerpt() are picking up the part of the javascript and appending it to the end of the text returned from get\_the\_excerpt(). I suppose this is caused by the fact th... | Read [this post](http://digitalnature.eu/blog/2011/09/12/how-to-correctly-hook-your-filter-to-the-post-content/). In your myTest\_get\_social() function, you need to check if the excerpt filter is active. If it is, just return the content and do nothing else:
```
if(current_filter() === 'get_the_excerpt')
return ... |
31,888 | <p>I am trying to sharding BLOGUPLOADDIR but couldnt success atm. This is default one:</p>
<pre><code>define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );
</code></pre>
<p>I am trying to set it:</p>
<pre><code>if($wpdb->blogid<10){
$bloggroup = 'global';
}else{
$bloggrou... | [
{
"answer_id": 31889,
"author": "EarnestoDev",
"author_id": 8211,
"author_profile": "https://wordpress.stackexchange.com/users/8211",
"pm_score": -1,
"selected": false,
"text": "<p>Define it in <strong>wp-config.php</strong>. The problem is you won't have access to the <strong>$wpdb->blo... | 2011/10/24 | [
"https://wordpress.stackexchange.com/questions/31888",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1372/"
] | I am trying to sharding BLOGUPLOADDIR but couldnt success atm. This is default one:
```
define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );
```
I am trying to set it:
```
if($wpdb->blogid<10){
$bloggroup = 'global';
}else{
$bloggroup = 'bloggroup'.floor($wpdb->blogid/2000+1); /... | Copy the body of `wp-includes/ms-settings.php` into `sunrise.php`, from line 25 to line 127. At the bottom, add your `BLOGUPLOADDIR` defines.
```
// from ms-settings.php
ms_subdomain_constants();
if ( !isset( $current_site ) || !isset( $current_blog ) ) {
// [trimmed, but you need the whole if block]
}
// end of ... |
31,890 | <p>I'm trying to use the search query along with an array of arguments to narrow down search results, but I'm failing horribly. This is what I have so far.</p>
<pre><code>$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$query_string = 's=test&category=wordpress'
$s_array = array(
... | [
{
"answer_id": 31962,
"author": "John P Bloch",
"author_id": 11,
"author_profile": "https://wordpress.stackexchange.com/users/11",
"pm_score": 3,
"selected": true,
"text": "<p>I'd suggest not using <code>$query_string</code> to simplify things. If you're using an array, stick with the ar... | 2011/10/24 | [
"https://wordpress.stackexchange.com/questions/31890",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9690/"
] | I'm trying to use the search query along with an array of arguments to narrow down search results, but I'm failing horribly. This is what I have so far.
```
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$query_string = 's=test&category=wordpress'
$s_array = array(
'post_type' =>... | I'd suggest not using `$query_string` to simplify things. If you're using an array, stick with the array form for the query variables:
```
global $wp;
$paged = ((int)get_query_var('paged')) ? (int)get_query_var('paged') : 1;
$s_array = array(
'post_type' => 'blog',
'caller_get_posts' => 1,
'paged' => $page... |
31,902 | <p>I have a difficult post a page problem.
I have this code :</p>
<pre><code>function wpse31701_4filter_query() {
global $wp_query;
// Check year and month
$wp_query->set('orderby', 'date'); $wp_query->set('order', 'ASC');
if ( $wp_query->get( 'year' ) == 2005 and $wp_query->get( 'monthnum' ) == 9 )
... | [
{
"answer_id": 31962,
"author": "John P Bloch",
"author_id": 11,
"author_profile": "https://wordpress.stackexchange.com/users/11",
"pm_score": 3,
"selected": true,
"text": "<p>I'd suggest not using <code>$query_string</code> to simplify things. If you're using an array, stick with the ar... | 2011/10/24 | [
"https://wordpress.stackexchange.com/questions/31902",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9629/"
] | I have a difficult post a page problem.
I have this code :
```
function wpse31701_4filter_query() {
global $wp_query;
// Check year and month
$wp_query->set('orderby', 'date'); $wp_query->set('order', 'ASC');
if ( $wp_query->get( 'year' ) == 2005 and $wp_query->get( 'monthnum' ) == 9 )
// Check page number to... | I'd suggest not using `$query_string` to simplify things. If you're using an array, stick with the array form for the query variables:
```
global $wp;
$paged = ((int)get_query_var('paged')) ? (int)get_query_var('paged') : 1;
$s_array = array(
'post_type' => 'blog',
'caller_get_posts' => 1,
'paged' => $page... |
31,909 | <p>I've taken over the maintainance of a large WP-MS powered site. The site has ~200 templates, many page specific, and with no standard naming procedure.</p>
<p>It would save a lot of time if while surfing around the site I can see the template names which make up the current page. Is this possible? I've looked at th... | [
{
"answer_id": 31916,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p>The following functions do 3 things: </p>\n\n<ul>\n<li>Show the template hierarchy for the current requesst</li>\n<... | 2011/10/24 | [
"https://wordpress.stackexchange.com/questions/31909",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9702/"
] | I've taken over the maintainance of a large WP-MS powered site. The site has ~200 templates, many page specific, and with no standard naming procedure.
It would save a lot of time if while surfing around the site I can see the template names which make up the current page. Is this possible? I've looked at the debug pl... | this is also a quick way;
```
<!--
<?php print_r( debug_backtrace() ) ?>
-->
```
paste it just before the closing tag |
31,912 | <p>I seem to have exhausted all the references on this subject, but if this is a duplicate post my apologies.</p>
<p>I am having a problem where ANY custom post page displays the 404.php file's error content, regardless of method of getting there. This includes simply going to something as rudimentary as <a href="http... | [
{
"answer_id": 31915,
"author": "Samuel Hulick",
"author_id": 7084,
"author_profile": "https://wordpress.stackexchange.com/users/7084",
"pm_score": 3,
"selected": true,
"text": "<p>As soon as I was done asking the question, I went to close functions.php for the night and happened to noti... | 2011/10/24 | [
"https://wordpress.stackexchange.com/questions/31912",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7084/"
] | I seem to have exhausted all the references on this subject, but if this is a duplicate post my apologies.
I am having a problem where ANY custom post page displays the 404.php file's error content, regardless of method of getting there. This includes simply going to something as rudimentary as <http://domain.com/?p=1... | As soon as I was done asking the question, I went to close functions.php for the night and happened to notice the custom post types were being registered along with other admin-specific features inside an `if (is_admin()) {` evaluator. Taking them out of that did the trick.
**Reasonably enough, it looks like custom po... |
31,933 | <p>I'm working on a site that has a fairly large page structure a few levels deep - in some sections there are a lot of pages.</p>
<p>The basic setup is something like this...</p>
<pre>
Parent
Parent
Parent
-Child
-Child
--Grandchild
--Grandchild
--Grandchild
---GreatGrandchild
-Child
-Child
--Grandchild
--Grandchild... | [
{
"answer_id": 31937,
"author": "Maxim Krizhanovsky",
"author_id": 8294,
"author_profile": "https://wordpress.stackexchange.com/users/8294",
"pm_score": 2,
"selected": false,
"text": "<p>Well, you can use the depth argument to control how many levels deep you want to show, and I've creat... | 2011/10/24 | [
"https://wordpress.stackexchange.com/questions/31933",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9712/"
] | I'm working on a site that has a fairly large page structure a few levels deep - in some sections there are a lot of pages.
The basic setup is something like this...
```
Parent
Parent
Parent
-Child
-Child
--Grandchild
--Grandchild
--Grandchild
---GreatGrandchild
-Child
-Child
--Grandchild
--Grandchild
--Grandchild
-... | This *should* work, using nothing more than the available argument-array parameters for [`wp_list_pages()`](http://codex.wordpress.org/Function_Reference/wp_list_pages): specifically, `depth` and `child_of`.
To display one level of hierarchy, for descendant pages of the current page:
```
<?php
// Globalize the $post ... |
31,941 | <p>I have been attempting to disable the ability to collapse admin meta boxes. By the looks of it WordPress creates this functionality in postbox.js /wp-admin/js/ but I have been unable to find a hook or suitable JavaScript to overwrite the built in functions.</p>
<p>This is a some test code I am working with:</p>
<p... | [
{
"answer_id": 32040,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 3,
"selected": true,
"text": "<p>Add this to your functions file and it will kill the metabox toggles:</p>\n\n<pre><code>function kill_postbo... | 2011/10/24 | [
"https://wordpress.stackexchange.com/questions/31941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3310/"
] | I have been attempting to disable the ability to collapse admin meta boxes. By the looks of it WordPress creates this functionality in postbox.js /wp-admin/js/ but I have been unable to find a hook or suitable JavaScript to overwrite the built in functions.
This is a some test code I am working with:
```
jQuery('.pos... | Add this to your functions file and it will kill the metabox toggles:
```
function kill_postbox(){
global $wp_scripts;
$footer_scripts = $wp_scripts->in_footer;
foreach($footer_scripts as $key => $script){
if('postbox' === $script)
unset($wp_scripts->in_footer[$key]);
}
}
add_action... |
31,942 | <p>Ok so i've got categories like setup like this.</p>
<pre><code>Products
Category A
Sub Category 1
Sub Category 2
Category B
Category C
</code></pre>
<p>What i need is to have the Products category page showing the main Categories (A,B,C). </p>
<p>The main Category pages (A,B,C) showing thei... | [
{
"answer_id": 32040,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 3,
"selected": true,
"text": "<p>Add this to your functions file and it will kill the metabox toggles:</p>\n\n<pre><code>function kill_postbo... | 2011/10/24 | [
"https://wordpress.stackexchange.com/questions/31942",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9218/"
] | Ok so i've got categories like setup like this.
```
Products
Category A
Sub Category 1
Sub Category 2
Category B
Category C
```
What i need is to have the Products category page showing the main Categories (A,B,C).
The main Category pages (A,B,C) showing their sub Categories (1,2).
Then the... | Add this to your functions file and it will kill the metabox toggles:
```
function kill_postbox(){
global $wp_scripts;
$footer_scripts = $wp_scripts->in_footer;
foreach($footer_scripts as $key => $script){
if('postbox' === $script)
unset($wp_scripts->in_footer[$key]);
}
}
add_action... |
31,943 | <p>There is the option to turn off trackbacks/pingbacks under <code>Settings > Discussion</code>.</p>
<p>But I'd like remove the <code>X-Pingback</code> header WordPress sends and completely remove the the <code>trackback</code> endpoint.</p>
<p>Is there a way to do this?</p>
| [
{
"answer_id": 31948,
"author": "EarnestoDev",
"author_id": 8211,
"author_profile": "https://wordpress.stackexchange.com/users/8211",
"pm_score": 5,
"selected": true,
"text": "<pre><code><?php\n/*\nPlugin Name: [RPC] XMLRPCless Blog\nPlugin URI: http://earnestodev.com/\nDescription: D... | 2011/10/24 | [
"https://wordpress.stackexchange.com/questions/31943",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6035/"
] | There is the option to turn off trackbacks/pingbacks under `Settings > Discussion`.
But I'd like remove the `X-Pingback` header WordPress sends and completely remove the the `trackback` endpoint.
Is there a way to do this? | ```
<?php
/*
Plugin Name: [RPC] XMLRPCless Blog
Plugin URI: http://earnestodev.com/
Description: Disable XMLRPC advertising/functionality blog-wide.
Version: 0.0.7
Author: EarnestoDev
Author URI: http://earnestodev.com/
*/
// Disable X-Pingback HTTP Header.
add_filter('wp_headers', function($headers, $wp_query){
if... |
31,951 | <p>I have a custom theme that displays the excerpt:</p>
<pre><code> $data = get_the_excerpt();
if ($data) echo "<div class='excerpt'>$data</div>";
</code></pre>
<p>if nothing is entered in the excerpt field in the post editor, Wordpress <a href="http://codex.wordpress.org/Excerpt#Excerpt.2C_automa... | [
{
"answer_id": 31957,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": true,
"text": "<p>Try using <code>$post->post_excerpt</code> instead:</p>\n\n<pre><code>// globalize $post, just in case\ng... | 2011/10/24 | [
"https://wordpress.stackexchange.com/questions/31951",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2161/"
] | I have a custom theme that displays the excerpt:
```
$data = get_the_excerpt();
if ($data) echo "<div class='excerpt'>$data</div>";
```
if nothing is entered in the excerpt field in the post editor, Wordpress [will automatically use the auto-generated teaser](http://codex.wordpress.org/Excerpt#Excerpt.2C_aut... | Try using `$post->post_excerpt` instead:
```
// globalize $post, just in case
global $post;
// find out if the post has a defined excerpt
$data = $post->post_excerpt;
// If so, output something
if ($data) echo "<div class='excerpt'>$data</div>";
```
This method will bypass the auto-excerpt generation inherent in `ge... |
31,956 | <p>Am I losing my mind? I seem to recall that somewhere in the Admin back-end there was a page that basically listed out all the fields within wp_options. Does this ring a bell to anyone else? I thought maybe it was a MU thing but it's not there either. At one point I seem to recall running into a page where you could ... | [
{
"answer_id": 31958,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code>http://example.com/wp-admin/options.php\n</code></pre>\n\n<p>Which lists <em>all</em... | 2011/10/24 | [
"https://wordpress.stackexchange.com/questions/31956",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3687/"
] | Am I losing my mind? I seem to recall that somewhere in the Admin back-end there was a page that basically listed out all the fields within wp\_options. Does this ring a bell to anyone else? I thought maybe it was a MU thing but it's not there either. At one point I seem to recall running into a page where you could ed... | ```
// Adds 'ALL' options page - only accessible for admins and custom roles that have the 'manage_options' capability.
function wpse31956_all_settings_page()
{
add_options_page( __('All'), __('All'), 'manage_options', 'options.php' );
}
add_action( 'admin_menu', 'wpse31956_all_settings_page' );
```
Note: As I j... |
31,970 | <p>I'm using site tags for a glossary. I would like to display a link to the tagged page if the tag exists, otherwise just display the tag title. Is there a check which would allow me to determine if the tag is has been tagged on posts?</p>
<pre><code> $tags = get_tags( array( 'hide_empty' => false ) );
if (... | [
{
"answer_id": 31972,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 4,
"selected": true,
"text": "<p>Try using the <a href=\"http://codex.wordpress.org/Function_Reference/has_tag\" rel=\"noreferrer\"><code>has... | 2011/10/24 | [
"https://wordpress.stackexchange.com/questions/31970",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3296/"
] | I'm using site tags for a glossary. I would like to display a link to the tagged page if the tag exists, otherwise just display the tag title. Is there a check which would allow me to determine if the tag is has been tagged on posts?
```
$tags = get_tags( array( 'hide_empty' => false ) );
if ($tags) {
fo... | Try using the [`has_tag()`](http://codex.wordpress.org/Function_Reference/has_tag) conditional template tag. e.g., to query for the tag "foobar":
```
<?php
if ( has_tag( 'foobar' ) ) {
// The current post has the tag "foobar";
// do something
} else {
// The current post DOES NOT have the tag "foobar";
... |
31,971 | <p>I've created a custom post type for "testimonials" as well as rearranged the edit post display with custom columns for that post type... Everything works as expected EXCEPT for the fact that when I hover over one of these custom posts, the list of "action links" that normally appears beneath it enabling you to edit/... | [
{
"answer_id": 31979,
"author": "helenhousandi",
"author_id": 2226,
"author_profile": "https://wordpress.stackexchange.com/users/2226",
"pm_score": 2,
"selected": false,
"text": "<p>Correct, without the title column, the row actions don't have a place to show. I haven't tried doing this ... | 2011/10/24 | [
"https://wordpress.stackexchange.com/questions/31971",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9665/"
] | I've created a custom post type for "testimonials" as well as rearranged the edit post display with custom columns for that post type... Everything works as expected EXCEPT for the fact that when I hover over one of these custom posts, the list of "action links" that normally appears beneath it enabling you to edit/del... | Ok, so it may not be the most efficient method... but I've found a solution. In the end, I wound up having to write a custom function to handle the addition of the row actions for each post. Here's how it turned out:
```
function wpg_row_actions() {
global $post;
if($post->post_type == 'page') {
if(!current_us... |
32,000 | <p>This is an odd query I have and wondered if anybody can shed some light on it?</p>
<p>We have a number WordPress multi-site (formally Mu) install, but on nearly all the sites on multiple installs we are getting this script tag...</p>
<pre><code><script src='http://[parent-domain]/?dm=[random-string]&amp;act... | [
{
"answer_id": 32012,
"author": "Ijaas",
"author_id": 9085,
"author_profile": "https://wordpress.stackexchange.com/users/9085",
"pm_score": 2,
"selected": false,
"text": "<p>It is added by the Domain Mapping Plugin and i believe (i might be wrong) it is used to log users into all MU site... | 2011/10/24 | [
"https://wordpress.stackexchange.com/questions/32000",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | This is an odd query I have and wondered if anybody can shed some light on it?
We have a number WordPress multi-site (formally Mu) install, but on nearly all the sites on multiple installs we are getting this script tag...
```
<script src='http://[parent-domain]/?dm=[random-string]&action=load&blogid=1&si... | It is added by the Domain Mapping Plugin and i believe (i might be wrong) it is used to log users into all MU sites with a single login.
to remove it:
```
add_action('wp_loaded', 'remove_unwanted_js');
function remove_unwanted_js(){
remove_action( 'wp_head', 'remote_login_js_loader' );
}
``` |
32,004 | <p>I am working with site that is done with WordPress, and I need to add some parts that are outside WP, and to check user login, Logging users outside WP.</p>
<p>I tried with md5 of password but it's not...</p>
<p>I tried this code:</p>
<pre><code>require_once( 'wp-includes/class-phpass.php' );
$wp_hasher = new Pas... | [
{
"answer_id": 32018,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 4,
"selected": true,
"text": "<p>Based on your other question ... it <em>sounds</em> like you're trying to validate a given plaintext password against ... | 2011/10/24 | [
"https://wordpress.stackexchange.com/questions/32004",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9722/"
] | I am working with site that is done with WordPress, and I need to add some parts that are outside WP, and to check user login, Logging users outside WP.
I tried with md5 of password but it's not...
I tried this code:
```
require_once( 'wp-includes/class-phpass.php' );
$wp_hasher = new PasswordHash( 8, TRUE );
$passw... | Based on your other question ... it *sounds* like you're trying to validate a given plaintext password against what's stored in the database. Here's the function WordPress uses to do just that:
```
function wp_check_password($password, $hash, $user_id = '') {
global $wp_hasher;
// If the hash is still md5...
... |
32,010 | <p>I've created a custom post type with 2 custom fields attached to it... When I create a post of this type and fill in the custom fields, the data is, in fact, saved to the db... However, if I trash one of them, then that post's custom fields data is deleted from the database.</p>
<p>I thought trashing was just suppo... | [
{
"answer_id": 32052,
"author": "Nero_DCLXVI",
"author_id": 9665,
"author_profile": "https://wordpress.stackexchange.com/users/9665",
"pm_score": 3,
"selected": true,
"text": "<p>It seems that the action save_post gets fired when sending a post to the trash... Therefore, my custom metada... | 2011/10/25 | [
"https://wordpress.stackexchange.com/questions/32010",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9665/"
] | I've created a custom post type with 2 custom fields attached to it... When I create a post of this type and fill in the custom fields, the data is, in fact, saved to the db... However, if I trash one of them, then that post's custom fields data is deleted from the database.
I thought trashing was just supposed to bas... | It seems that the action save\_post gets fired when sending a post to the trash... Therefore, my custom metadata save function was being activated with no $\_POST data to send thru it.
To circumvent this, I wound up adding a nonce to the save function.
```
function wpg_testimonial_author() {
global $post;
$custom... |
32,021 | <p>I need to replace all post_content in a particular tag/category to the desired one i have. is their a plugin to accomplish it or is their a query to finish this. Iam sick of doing this manually, is their a way to accomplish it.</p>
| [
{
"answer_id": 32055,
"author": "Álex Acuña Viera",
"author_id": 6099,
"author_profile": "https://wordpress.stackexchange.com/users/6099",
"pm_score": 1,
"selected": false,
"text": "<p>This is what I mean:</p>\n\n<pre><code><?php \n$tochange = get_posts('numberposts=-1&post_type=a... | 2011/10/25 | [
"https://wordpress.stackexchange.com/questions/32021",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7376/"
] | I need to replace all post\_content in a particular tag/category to the desired one i have. is their a plugin to accomplish it or is their a query to finish this. Iam sick of doing this manually, is their a way to accomplish it. | This is what I mean:
```
<?php
$tochange = get_posts('numberposts=-1&post_type=any&category_name=category-name-you-want-to-change');
foreach($tochange as $post){
setup_postdata($post);
$contentchange = ''; /*here you do the magic, string replace or whathever you want to do*/
$tochange = array();
... |
32,041 | <p><strong>Scenario:</strong> I have a mother site <code>example.com</code> which has a blog and say about 12 category. I also have 12 other wordpress site. Some in the subdomain of <code>example.com</code> and some are different domains. 12 Sites represent 12 category. When I Post on a category the post should be also... | [
{
"answer_id": 32055,
"author": "Álex Acuña Viera",
"author_id": 6099,
"author_profile": "https://wordpress.stackexchange.com/users/6099",
"pm_score": 1,
"selected": false,
"text": "<p>This is what I mean:</p>\n\n<pre><code><?php \n$tochange = get_posts('numberposts=-1&post_type=a... | 2011/10/25 | [
"https://wordpress.stackexchange.com/questions/32041",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3094/"
] | **Scenario:** I have a mother site `example.com` which has a blog and say about 12 category. I also have 12 other wordpress site. Some in the subdomain of `example.com` and some are different domains. 12 Sites represent 12 category. When I Post on a category the post should be also posted to a appropriate category site... | This is what I mean:
```
<?php
$tochange = get_posts('numberposts=-1&post_type=any&category_name=category-name-you-want-to-change');
foreach($tochange as $post){
setup_postdata($post);
$contentchange = ''; /*here you do the magic, string replace or whathever you want to do*/
$tochange = array();
... |
32,046 | <p>I've created a class to dynamically create pages. I'm checking to see if the page exists by comparing the new page's title to <code>post_name</code>. The comparison seems to work ok, but even if there is a match the page is created anyway and I can't figure out why.</p>
<p>My code looks like this:</p>
<pre><code>c... | [
{
"answer_id": 32050,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>Why are you comparing <code>$post->post_name</code> to <code>$this->title</code>? You should be compar... | 2011/10/25 | [
"https://wordpress.stackexchange.com/questions/32046",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3430/"
] | I've created a class to dynamically create pages. I'm checking to see if the page exists by comparing the new page's title to `post_name`. The comparison seems to work ok, but even if there is a match the page is created anyway and I can't figure out why.
My code looks like this:
```
class createDynamicPage {
public... | Why are you comparing `$post->post_name` to `$this->title`? You should be comparing *slug* to *slug*.
Try changing your comparison from this:
```
if( strtolower( $page->post_name ) == strtolower( $this->title ) )
```
...to this:
```
if( strtolower( $page->post_name ) == strtolower( $this->slug ) )
```
Also, I mi... |
32,051 | <p>Is there a function in the wordpress api that lets me programatically add pages ?</p>
<p>something on the lines of :</p>
<pre><code>add_page($title,$content)
</code></pre>
<p>Is there such a function ?</p>
| [
{
"answer_id": 32053,
"author": "onetrickpony",
"author_id": 1986,
"author_profile": "https://wordpress.stackexchange.com/users/1986",
"pm_score": 4,
"selected": true,
"text": "<p>Yes, it's <a href=\"http://codex.wordpress.org/Function_Reference/wp_insert_post\"><code>wp_insert_post()</c... | 2011/10/25 | [
"https://wordpress.stackexchange.com/questions/32051",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3933/"
] | Is there a function in the wordpress api that lets me programatically add pages ?
something on the lines of :
```
add_page($title,$content)
```
Is there such a function ? | Yes, it's [`wp_insert_post()`](http://codex.wordpress.org/Function_Reference/wp_insert_post). |
32,056 | <p>I have the following code in my sidebar to list all the taxonomy categories.</p>
<pre><code><div class="left">
<h1>Categories</h1>
<?php
//list terms in a given taxonomy using wp_list_categories (also useful as a widget if using a PHP Code plugin)
$taxonomy = ... | [
{
"answer_id": 32058,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 1,
"selected": false,
"text": "<p>By what criterion do you need to order your taxonomy terms?</p>\n\n<p>See this argument-array key:</p>\n\n<... | 2011/10/25 | [
"https://wordpress.stackexchange.com/questions/32056",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9498/"
] | I have the following code in my sidebar to list all the taxonomy categories.
```
<div class="left">
<h1>Categories</h1>
<?php
//list terms in a given taxonomy using wp_list_categories (also useful as a widget if using a PHP Code plugin)
$taxonomy = 'workcategories';
$orderby ... | By what criterion do you need to order your taxonomy terms?
See this argument-array key:
```
'orderby' => $orderby,
```
Per the documentation for [`wp_list_categories()`](http://codex.wordpress.org/Template_Tags/wp_list_categories), the `orderby` parameter can take the following values:
* `'ID'` - Default
* `... |
32,064 | <p>I am working on anew blog. I am logged in as administrator, and above every post there is a option to 'edit this entry'.</p>
<p>Can I have WordPress set up so that even is I am logged in as administrator, I will still view the front end of the website as if I was not logged in. This was I can see how the user would... | [
{
"answer_id": 32065,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>Those edit links are Theme-dependent, via the <a href=\"http://codex.wordpress.org/Function_Reference/edit_... | 2011/10/25 | [
"https://wordpress.stackexchange.com/questions/32064",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7781/"
] | I am working on anew blog. I am logged in as administrator, and above every post there is a option to 'edit this entry'.
Can I have WordPress set up so that even is I am logged in as administrator, I will still view the front end of the website as if I was not logged in. This was I can see how the user would see the p... | See this [related question](https://wordpress.stackexchange.com/questions/22591/how-to-remove-all-instances-of-edit-post-link). You should be able to add this code to your themes functions.php
```
add_filter( 'edit_post_link', '__return_false' );
``` |
32,072 | <p>How do I get the page title of the upper most parent page of the page the visitor is currently on?</p>
<p>Let me describe:</p>
<p>I have this page structure:</p>
<ul>
<li>Example Title 1
<ul>
<li>Example Title 1-1
<ul>
<li>Example Title 1-1-1</li>
<li>Example Title 1-1-2</li>
</ul></li>
<li>Example Title 1-2</li>... | [
{
"answer_id": 32075,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 5,
"selected": true,
"text": "<p>Found this way:</p>\n\n<pre><code>if ( 0 == $post->post_parent ) {\n the_title();\n} else {\n $parents = g... | 2011/10/25 | [
"https://wordpress.stackexchange.com/questions/32072",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4610/"
] | How do I get the page title of the upper most parent page of the page the visitor is currently on?
Let me describe:
I have this page structure:
* Example Title 1
+ Example Title 1-1
- Example Title 1-1-1
- Example Title 1-1-2
+ Example Title 1-2
* Example Title 2
* Example Title 3
* Example Title 4
Here is wh... | Found this way:
```
if ( 0 == $post->post_parent ) {
the_title();
} else {
$parents = get_post_ancestors( $post->ID );
echo apply_filters( "the_title", get_the_title( end ( $parents ) ) );
}
```
Anyone got a better way please answer. |
32,093 | <p>Hi I am trying to figure out on how to get the "view" link on the manage posts / custom post types and pages to open in a new tab or window. </p>
<p><img src="https://i.stack.imgur.com/4RAdz.png" alt="A screenshot of what I am talking about."></p>
<p>I know it is probably possible to do via the functions.php file ... | [
{
"answer_id": 32075,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 5,
"selected": true,
"text": "<p>Found this way:</p>\n\n<pre><code>if ( 0 == $post->post_parent ) {\n the_title();\n} else {\n $parents = g... | 2011/10/25 | [
"https://wordpress.stackexchange.com/questions/32093",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8337/"
] | Hi I am trying to figure out on how to get the "view" link on the manage posts / custom post types and pages to open in a new tab or window.

I know it is probably possible to do via the functions.php file of the theme and would much rat... | Found this way:
```
if ( 0 == $post->post_parent ) {
the_title();
} else {
$parents = get_post_ancestors( $post->ID );
echo apply_filters( "the_title", get_the_title( end ( $parents ) ) );
}
```
Anyone got a better way please answer. |
32,099 | <p>I'm stuck on this, and have no idea what I'm doing. I have a custom post type called areas, that is hierarchical. We want to pass a variable into the page, and have it be pretty. Currently, it is:</p>
<pre><code>http://www.example.com/area/alabama/birmingham/?action=places
</code></pre>
<p>We'd like it to be:</p>
... | [
{
"answer_id": 32102,
"author": "Nero_DCLXVI",
"author_id": 9665,
"author_profile": "https://wordpress.stackexchange.com/users/9665",
"pm_score": 1,
"selected": false,
"text": "<p>Here's another question very similar to yours with a working answer... See if it helps.</p>\n\n<p><a href=\"... | 2011/10/25 | [
"https://wordpress.stackexchange.com/questions/32099",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9757/"
] | I'm stuck on this, and have no idea what I'm doing. I have a custom post type called areas, that is hierarchical. We want to pass a variable into the page, and have it be pretty. Currently, it is:
```
http://www.example.com/area/alabama/birmingham/?action=places
```
We'd like it to be:
```
http://www.example.com/ar... | ```
function add_places_rewrite_tags() {
add_rewrite_tag('%action%','([^&]+)');
}
add_action( 'init', 'add_places_rewrite_tags' );
```
First add the rewrite tag action (action=xxxx)
```
function add_places_rewrite_rules() {
add_rewrite_rule('^area/([^/]*)/places/?','index.php?post_type=area&name=$matches[1]&... |
32,100 | <p>I have set up a custom post type called 'Events'. For reasons that I'm not going to get into, I chose not use <code>archive-events.php</code> as the archive template for my Events. Instead, I decided to create a custom page template, <code>page-upcoming-events.php</code>, to use as an archive.</p>
<p>I wrote a cust... | [
{
"answer_id": 35287,
"author": "mgyura",
"author_id": 10765,
"author_profile": "https://wordpress.stackexchange.com/users/10765",
"pm_score": 3,
"selected": false,
"text": "<p>This is what I do for paging. I hope it helps you get on the right track, it may be overkill for what you are ... | 2011/10/25 | [
"https://wordpress.stackexchange.com/questions/32100",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9425/"
] | I have set up a custom post type called 'Events'. For reasons that I'm not going to get into, I chose not use `archive-events.php` as the archive template for my Events. Instead, I decided to create a custom page template, `page-upcoming-events.php`, to use as an archive.
I wrote a custom query in this template to pul... | This is what I do for paging. I hope it helps you get on the right track, it may be overkill for what you are trying to do...
First I set $paged:
```
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
```
Then build your $args array, make sure to call in:
```
'paged' => $paged
```
Run your que... |
32,103 | <p>How do I create a widget that only allows a single instance of a widget to be added through the Wordpress interface?</p>
<p>The default behaviour of widgets allows multiple instances to be added.</p>
<p>I am using the Example code from <a href="http://codex.wordpress.org/Widgets_API" rel="nofollow noreferrer">http... | [
{
"answer_id": 32104,
"author": "EarnestoDev",
"author_id": 8211,
"author_profile": "https://wordpress.stackexchange.com/users/8211",
"pm_score": -1,
"selected": false,
"text": "<p>You don't. It's too difficult to be worth it. It's how the JS editor thing works.</p>\n\n<p><strong>BUT</st... | 2011/10/25 | [
"https://wordpress.stackexchange.com/questions/32103",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4041/"
] | How do I create a widget that only allows a single instance of a widget to be added through the Wordpress interface?
The default behaviour of widgets allows multiple instances to be added.
I am using the Example code from <http://codex.wordpress.org/Widgets_API>
I have seen a [similar question](https://wordpress.st... | I know this is a super old question, but searching for solutions 8 years later didn't yield many results aside from this unresolved question (and a few other vague answers). Nothing I found on this site worked for me so if others arrive on this page looking for a way to limit a widget-area to single-use from a specific... |
32,111 | <p>When i am on the single.php page, i show the first image attachment.
then i would like to load the next (and previous) image attachments without reloading the page. </p>
<p>so in single.php i started with this to retrieve an array with the images html: </p>
<pre><code><?php $args = array('post_type' => 'att... | [
{
"answer_id": 32187,
"author": "rogaroga",
"author_id": 9749,
"author_profile": "https://wordpress.stackexchange.com/users/9749",
"pm_score": 1,
"selected": false,
"text": "<p>@milo thanks ! i used <a href=\"http://ottopress.com/2010/passing-parameters-from-php-to-javascripts-in-plugins... | 2011/10/25 | [
"https://wordpress.stackexchange.com/questions/32111",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9749/"
] | When i am on the single.php page, i show the first image attachment.
then i would like to load the next (and previous) image attachments without reloading the page.
so in single.php i started with this to retrieve an array with the images html:
```
<?php $args = array('post_type' => 'attachment', 'post_mime_type' ... | @milo thanks ! i used [a technique](http://ottopress.com/2010/passing-parameters-from-php-to-javascripts-in-plugins/) found on the page you sent.
it's almost working.
I added this at the end of the previous single.php code :
```
array_unshift($attachments_list,"");
wp_enqueue_script('myscript');
wp_localize_scrip... |
32,139 | <p>This is my category / archive page </p>
<p>i want to include a template before loop </p>
<p>but i cant get posts based on category, it showing latest post only on every page.</p>
<p>when i removed this line before the loop</p>
<pre><code><?php include( TEMPLATEPATH . '/includes/tb/hot_posts.tpl.php' ); ?>
... | [
{
"answer_id": 32145,
"author": "Michael",
"author_id": 4884,
"author_profile": "https://wordpress.stackexchange.com/users/4884",
"pm_score": 2,
"selected": true,
"text": "<p>try and add </p>\n\n<pre><code><?php wp_reset_query(); ?> \n</code></pre>\n\n<p>at the end of your template... | 2011/10/26 | [
"https://wordpress.stackexchange.com/questions/32139",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8503/"
] | This is my category / archive page
i want to include a template before loop
but i cant get posts based on category, it showing latest post only on every page.
when i removed this line before the loop
```
<?php include( TEMPLATEPATH . '/includes/tb/hot_posts.tpl.php' ); ?>
```
it work smoothly, but i need this t... | try and add
```
<?php wp_reset_query(); ?>
```
at the end of your template.
<http://codex.wordpress.org/Function_Reference/wp_reset_query> |
32,172 | <p>I know I'm probably doing something dumb here but I just can't get this to run. I'm trying to set up a little API for my plugin and to create a class to display admin notices a little easier. Here's what I have:</p>
<pre><code>// Send data to class to get HTML for admin notice
$efpd=Efpdd::getInstance();
$plugin_up... | [
{
"answer_id": 32176,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 4,
"selected": true,
"text": "<p>Try this. I cleaned up your arg array and placed everything in a function. Also, why are you using the getIn... | 2011/10/26 | [
"https://wordpress.stackexchange.com/questions/32172",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2415/"
] | I know I'm probably doing something dumb here but I just can't get this to run. I'm trying to set up a little API for my plugin and to create a class to display admin notices a little easier. Here's what I have:
```
// Send data to class to get HTML for admin notice
$efpd=Efpdd::getInstance();
$plugin_update = $efpd->... | Try this. I cleaned up your arg array and placed everything in a function. Also, why are you using the getInstance method when your efpd\_admin\_notice is public? See the code below for accessing this method properly.
```
function plugin_update(){
$plugin_update = Efpdd::efpd_admin_notice(array(
'type' => ... |
32,186 | <p>Without using plugins, how to create a custom WordPress navigation menu with the code?
<br/>I have <strong>Wordpress</strong> ver <strong>3.2.1</strong>
<br/>and <strong>Buddypress</strong> ver <strong>1.5.1</strong></p>
<p>I would like to create a menu.</p>
<p>I would like to place the buddypress menu navigation ... | [
{
"answer_id": 32176,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 4,
"selected": true,
"text": "<p>Try this. I cleaned up your arg array and placed everything in a function. Also, why are you using the getIn... | 2011/10/26 | [
"https://wordpress.stackexchange.com/questions/32186",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8984/"
] | Without using plugins, how to create a custom WordPress navigation menu with the code?
I have **Wordpress** ver **3.2.1**
and **Buddypress** ver **1.5.1**
I would like to create a menu.
I would like to place the buddypress menu navigation items into one item (social).
when you pass the mouse over this item it appea... | Try this. I cleaned up your arg array and placed everything in a function. Also, why are you using the getInstance method when your efpd\_admin\_notice is public? See the code below for accessing this method properly.
```
function plugin_update(){
$plugin_update = Efpdd::efpd_admin_notice(array(
'type' => ... |
32,189 | <p>I hope i can explain this right , what im trying to do is use the default word press loop to show all my posts etc.. but for the first post I would like it to be styled completely different depending on what parent category it was published in, so there would be a lot going on in that first post.</p>
<p>Right now I... | [
{
"answer_id": 32190,
"author": "Michael",
"author_id": 4884,
"author_profile": "https://wordpress.stackexchange.com/users/4884",
"pm_score": 4,
"selected": true,
"text": "<p>one loop with a conditional statement to catch the first post should work;\nexample:</p>\n\n<pre><code><?php i... | 2011/10/26 | [
"https://wordpress.stackexchange.com/questions/32189",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6381/"
] | I hope i can explain this right , what im trying to do is use the default word press loop to show all my posts etc.. but for the first post I would like it to be styled completely different depending on what parent category it was published in, so there would be a lot going on in that first post.
Right now I'm some wh... | one loop with a conditional statement to catch the first post should work;
example:
```
<?php if( $wp_query->current_post == 0 && !is_paged() ) : ?>
/*the output of the first post*?
<?php else : ?>
/*the output of all other posts*/
<?php endif; ?>
``` |
32,201 | <p>I'm working on adding a checkbox to my user registration page to opt-in to my e-mail list, and I'm not sure the proper way to have the checkbox ticked off by default. This is what I've got so far:</p>
<pre><code>// Checkbox to join list
add_action( 'register_form', 'email_opt_in' );
function email_opt_in() { ?>... | [
{
"answer_id": 32204,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 1,
"selected": false,
"text": "<p>You need to pass the <em>actual current</em> value of the option to <code>checked()</code>, rather than the... | 2011/10/26 | [
"https://wordpress.stackexchange.com/questions/32201",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9058/"
] | I'm working on adding a checkbox to my user registration page to opt-in to my e-mail list, and I'm not sure the proper way to have the checkbox ticked off by default. This is what I've got so far:
```
// Checkbox to join list
add_action( 'register_form', 'email_opt_in' );
function email_opt_in() { ?>
<p>
<lab... | I would add a hidden input field with the same name before the checkbox:
`<input type="hidden" name="email_opt_in" value="0" />`
Because the forms are processed sequentially you would get "0" if the form was submitted, but the checkbox wasn't checked (instead of not getting anything).
Then assume the checkbox is che... |
32,224 | <p>I want to show post count in my site by parent category.</p>
<p>Example -
We have 18 Tutorials, 15 Article, 3 Freebies</p>
| [
{
"answer_id": 32235,
"author": "Monirul Islam",
"author_id": 9456,
"author_profile": "https://wordpress.stackexchange.com/users/9456",
"pm_score": -1,
"selected": false,
"text": "<p>go here..you will find answer</p>\n\n<p><a href=\"http://jhherren.wordpress.com/2008/08/13/getting-the-nu... | 2011/10/27 | [
"https://wordpress.stackexchange.com/questions/32224",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9789/"
] | I want to show post count in my site by parent category.
Example -
We have 18 Tutorials, 15 Article, 3 Freebies | Here we'll use the function - [`get_categories()`](http://codex.wordpress.org/Function_Reference/get_categories) to grab all the available categories and store it as array, Then we'll loop through the array to display the list. Within the foreach loop we did a conditional check that is to determine if category is paren... |
32,228 | <p>How can I display a different style snippet if a user selects and option from my theme options page select box.</p>
<p>For example. To show the sidebar on the right a user would select "Right" and the default stylesheet would be used. However, if they chose "Left" to display it on the left, a small style snippet wo... | [
{
"answer_id": 32226,
"author": "Paul",
"author_id": 9485,
"author_profile": "https://wordpress.stackexchange.com/users/9485",
"pm_score": 2,
"selected": false,
"text": "<p>There is no maintenance mode in core AFAIK.\nAnd as far as plugin's go, I prefer <a href=\"http://wordpress.org/ext... | 2011/10/27 | [
"https://wordpress.stackexchange.com/questions/32228",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7999/"
] | How can I display a different style snippet if a user selects and option from my theme options page select box.
For example. To show the sidebar on the right a user would select "Right" and the default stylesheet would be used. However, if they chose "Left" to display it on the left, a small style snippet would appear... | Yes there is. But it is primarily meant for short interruptions (such as during upgrades) and not very user-friendly. WP creates `.maintenance` file in root (with timestamp info about time) to trigger it and removes after it is done.
See [WordPress Maintenance Mode Without a Plugin](http://sivel.net/2009/06/wordpress-... |
32,234 | <p>Currently
I have this code</p>
<pre><code>$tag_list = get_the_tag_list('<ul><li>','</li><li>','</li></ul>');
</code></pre>
<p>and outputs:</p>
<pre><code><ul>
<li><a href="tag_link">tag_name</a></li>
....
</ul>
</code></pre>
<p>How... | [
{
"answer_id": 32236,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 4,
"selected": true,
"text": "<p>So, from the <a href=\"http://codex.wordpress.org/Function_Reference/get_the_tag_list\" rel=\"noreferrer\"><... | 2011/10/27 | [
"https://wordpress.stackexchange.com/questions/32234",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9215/"
] | Currently
I have this code
```
$tag_list = get_the_tag_list('<ul><li>','</li><li>','</li></ul>');
```
and outputs:
```
<ul>
<li><a href="tag_link">tag_name</a></li>
....
</ul>
```
How can I change it so it displays like this?
```
<ul>
<li><a href="tag_link"><span>tag_name</span></a></li>
....
<... | So, from the [`get_the_tag_list()`](http://codex.wordpress.org/Function_Reference/get_the_tag_list) Codex entry:
>
> * $before
> + (string) (optional) Leading text.
> + Default: 'Tags: '
> * $sep
> + (string) (optional) String to separate tags.
> + Default: ', '
> * $after
> + (string) (optional) Trailing text.
... |
32,254 | <p>I built a navigation menu using the native menu builder in WordPress 3. This is the code I use to render it:</p>
<pre><code><?php wp_nav_menu( array('menu' => 'Main Navigation','menu_id'=> 'headernav','menu_class'=>'navigate')); ?>
</code></pre>
<p>It renders exactly the way I would expect on every... | [
{
"answer_id": 32246,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 0,
"selected": false,
"text": "<p><code>get_footer();</code> and <code>get_sidebar();</code> include the files <code>footer.php</code> and ... | 2011/10/27 | [
"https://wordpress.stackexchange.com/questions/32254",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2355/"
] | I built a navigation menu using the native menu builder in WordPress 3. This is the code I use to render it:
```
<?php wp_nav_menu( array('menu' => 'Main Navigation','menu_id'=> 'headernav','menu_class'=>'navigate')); ?>
```
It renders exactly the way I would expect on every page **except** 404.php. This is how it r... | From OP comment:
>
> The footer.php file is all encrypted
>
>
>
**Do not download Themes from random sites**. [Only download Themes from trusted sources](http://www.chipbennett.net/2010/12/10/only-download-wordpress-themes-from-trusted-sources/), for exactly this reason.
The footer is encrypted, and the Theme is... |
32,257 | <p>Is it possible to create a permalink/template structure like this: </p>
<pre><code>www.example.com/attractions <-- post type archive
www.example.com/attractions/museums <-- taxonomy archive
www.example.com/attractions/van-gogh-museum <-- custom post type
</code></pre>
<p>After t... | [
{
"answer_id": 32263,
"author": "EarnestoDev",
"author_id": 8211,
"author_profile": "https://wordpress.stackexchange.com/users/8211",
"pm_score": 0,
"selected": false,
"text": "<p><strong>See if this answer helps:</strong>\n<a href=\"https://wordpress.stackexchange.com/questions/32137/ho... | 2011/10/27 | [
"https://wordpress.stackexchange.com/questions/32257",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7584/"
] | Is it possible to create a permalink/template structure like this:
```
www.example.com/attractions <-- post type archive
www.example.com/attractions/museums <-- taxonomy archive
www.example.com/attractions/van-gogh-museum <-- custom post type
```
After trying for days I can only get 1 of ... | ```
// Add the new post_type and taxonomy
add_action('init', function(){
// Add a post_type named 'testype'
register_post_type($postype = 'testype', $arguments = array(
'name' => $postype,
'label' => 'Test',
'public' => true,
'exclu... |
32,258 | <p>Is there a way to track logged in user activity? I'd like to see who logged in to the site each day and maybe see a specific persons login history. </p>
<p>Currently I have no idea which of the registered users are visiting my site. It's a private family site with <strong>~20 members</strong> and I'm just curious ... | [
{
"answer_id": 32269,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p>As it's a small site, you can do some \"real\" tracking:</p>\n\n<pre><code>// Update the visit time on *every* requ... | 2011/10/27 | [
"https://wordpress.stackexchange.com/questions/32258",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9795/"
] | Is there a way to track logged in user activity? I'd like to see who logged in to the site each day and maybe see a specific persons login history.
Currently I have no idea which of the registered users are visiting my site. It's a private family site with **~20 members** and I'm just curious to know who is and who i... | As it's a small site, you can do some "real" tracking:
```
// Update the visit time on *every* request
function wpse32258_update_usertracking(){
if ( is_user_logged_in() ) {
$user_ID = get_current_user_id();
$data = get_user_meta( $user_ID, 'user_tracking' );
$data[] = current_time( 'times... |
32,259 | <p>is there a way to set the order of posts via the url?</p>
<p>/orderby/date/order/desc/</p>
<p>i have tried several things with add_rewrite_rule whiteout success. </p>
<pre><code>add_action( 'init', 'wpse13483_init' );
function wpse13483_init()
{
add_rewrite_rule( 'category/(.+?)/orderby/([^/]+)/order/([^/]+)(... | [
{
"answer_id": 32262,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>Creating <em>URL rewrite</em> rules is something entirely different from <em>using URL query variables to s... | 2011/10/27 | [
"https://wordpress.stackexchange.com/questions/32259",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3978/"
] | is there a way to set the order of posts via the url?
/orderby/date/order/desc/
i have tried several things with add\_rewrite\_rule whiteout success.
```
add_action( 'init', 'wpse13483_init' );
function wpse13483_init()
{
add_rewrite_rule( 'category/(.+?)/orderby/([^/]+)/order/([^/]+)(/page/?([0-9]{1,}))?/?$', ... | adding this in the functions.php file works. Just **remember to re-save your permalinks** & empty the cache a few times to see the changes.
```
add_action( 'init', 'wpse13483_init' );
function wpse13483_init() {
add_rewrite_rule( 'category/(.+?)/orderby/([^/]+)?/?$', 'index.php?category_name=$matches[1]&orderby=$m... |
32,266 | <p>Can anyone tell me why this isn't working? Assuming two things here - 1. WP Query handles multiple page requests, and 2. doesn't need a reset because I'm creating a new WP Query.
What happens is I only get the last page to be shown (389). Above this code on the same page there is another WP Query that only fetches o... | [
{
"answer_id": 32280,
"author": "adrian7",
"author_id": 7171,
"author_profile": "https://wordpress.stackexchange.com/users/7171",
"pm_score": 1,
"selected": false,
"text": "<p>Because your posts are only saved whithin the $promo var and not in the $wp_query global var. I recommend you to... | 2011/10/27 | [
"https://wordpress.stackexchange.com/questions/32266",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3390/"
] | Can anyone tell me why this isn't working? Assuming two things here - 1. WP Query handles multiple page requests, and 2. doesn't need a reset because I'm creating a new WP Query.
What happens is I only get the last page to be shown (389). Above this code on the same page there is another WP Query that only fetches one ... | Because your posts are only saved whithin the $promo var and not in the $wp\_query global var. I recommend you to use get\_posts() <http://codex.wordpress.org/Template_Tags/get_posts> |
32,270 | <p>I am using this filter for Custom excerpts </p>
<pre><code><?php echo excerpt(90); ?>
</code></pre>
<p><a href="http://bavotasan.com/2009/limiting-the-number-of-words-in-your-excerpt-or-content-in-wordpress/" rel="nofollow">http://bavotasan.com/2009/limiting-the-number-of-words-in-your-excerpt-or-content-in-... | [
{
"answer_id": 32275,
"author": "Andy Adams",
"author_id": 6816,
"author_profile": "https://wordpress.stackexchange.com/users/6816",
"pm_score": 0,
"selected": false,
"text": "<p>After playing with your code, I don't see any bugs with the excerpt() function.</p>\n\n<p>I am guessing your ... | 2011/10/27 | [
"https://wordpress.stackexchange.com/questions/32270",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8503/"
] | I am using this filter for Custom excerpts
```
<?php echo excerpt(90); ?>
```
<http://bavotasan.com/2009/limiting-the-number-of-words-in-your-excerpt-or-content-in-wordpress/>
but this filter not working in first featured post showing default 55 words
else it's working fine
```
<?php
$count = 1;
if (have_posts... | Try to go in a completely different way about that and this code to your functions.php
```
// Variable excerpt length.
function dynamic_excerpt($length) { // Variable excerpt length. Length is set in characters
global $post;
$text = $post->post_excerpt;
if ( '' == $text ) {
$text = get_the_content('');
$text = apply_f... |
32,277 | <p>is there a way to hook / filter or add action that would be printed in the wp-config file? lets say i want to add some simple command like "empty the trash" aka</p>
<pre><code>define('EMPTY_TRASH_DAYS', 1 );
</code></pre>
<p>This should be changes in the wp-config but i want it to go with theme..</p>
<p>Any way ... | [
{
"answer_id": 32279,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 5,
"selected": true,
"text": "<p>There is, as far as I know, no way to hook into <code>wp-config.php</code> from a Theme. For one, <code>wp-c... | 2011/10/27 | [
"https://wordpress.stackexchange.com/questions/32277",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7990/"
] | is there a way to hook / filter or add action that would be printed in the wp-config file? lets say i want to add some simple command like "empty the trash" aka
```
define('EMPTY_TRASH_DAYS', 1 );
```
This should be changes in the wp-config but i want it to go with theme..
Any way to do that? | There is, as far as I know, no way to hook into `wp-config.php` from a Theme. For one, `wp-config.php` shouldn't be writeable; for another, `wp-config.php` is executed [well-before a Theme's `functions.php` file is parsed](http://codex.wordpress.org/Plugin_API/Action_Reference). For a great overview of how WordPress bo... |
32,285 | <p>I know this is a fairly common topic around here, but I can't seem to figure out a solution to my particular case from reading similar threads.</p>
<p>Basically, my permalink structure needs to be /%postname%/ for compatibility with a finicky plugin. The plugin authors may fix this in the future, but for now I need... | [
{
"answer_id": 40605,
"author": "Matthew Boynes",
"author_id": 12324,
"author_profile": "https://wordpress.stackexchange.com/users/12324",
"pm_score": 5,
"selected": true,
"text": "<p>Even though this is no longer a problem for you, I decided to pursue it for purely academic reasons. I g... | 2011/10/27 | [
"https://wordpress.stackexchange.com/questions/32285",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9802/"
] | I know this is a fairly common topic around here, but I can't seem to figure out a solution to my particular case from reading similar threads.
Basically, my permalink structure needs to be /%postname%/ for compatibility with a finicky plugin. The plugin authors may fix this in the future, but for now I need to come u... | Even though this is no longer a problem for you, I decided to pursue it for purely academic reasons. I got it working by prepending rewrite rules and filtering permalinks. Note that I wouldn't actually recommend doing this, but it's fun to know it's possible :)
```
function filter_post_link($permalink, $post) {
if... |
32,297 | <p>I want to check for an appropriate template in the theme folder before falling back to the file in my plugin directory. Here’s my code:</p>
<pre>add_filter('template_include', 'sermon_template_include');
function sermon_template_include($template) {
if(get_query_var('post_type') == 'wpfc_sermon') {
if (... | [
{
"answer_id": 32322,
"author": "Nicole",
"author_id": 8337,
"author_profile": "https://wordpress.stackexchange.com/users/8337",
"pm_score": 1,
"selected": false,
"text": "<p>I am not sure if this will work for you but it is worth a shot. I use this all the time for my custom post types ... | 2011/10/28 | [
"https://wordpress.stackexchange.com/questions/32297",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9810/"
] | I want to check for an appropriate template in the theme folder before falling back to the file in my plugin directory. Here’s my code:
```
add_filter('template_include', 'sermon_template_include');
function sermon_template_include($template) {
if(get_query_var('post_type') == 'wpfc_sermon') {
if ( is_arch... | So, I'm not sure exactly what is causing the problem, but you might try the following:
1. **Plugin file path**: replace `dirname(__FILE__)` with [`plugin_dir_path( __FILE__ )`](http://codex.wordpress.org/Function_Reference/plugin_dir_path)
2. **Theme file path**: replace `TEMPLATEDIR` with [`get_stylesheet_directory()... |
32,300 | <p>I am having private page.I want to show this page only when "subscriber" logged in."Editor" should not access this page.How can i set the privilege. </p>
| [
{
"answer_id": 32301,
"author": "Brooke.",
"author_id": 2204,
"author_profile": "https://wordpress.stackexchange.com/users/2204",
"pm_score": 3,
"selected": true,
"text": "<p>Without a plugin something like this should work </p>\n\n<pre><code> //functions.php\n function get_user_ro... | 2011/10/28 | [
"https://wordpress.stackexchange.com/questions/32300",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4022/"
] | I am having private page.I want to show this page only when "subscriber" logged in."Editor" should not access this page.How can i set the privilege. | Without a plugin something like this should work
```
//functions.php
function get_user_role() {
global $current_user;
$user_roles = $current_user->roles;
$user_role = array_shift($user_roles);
return $user_role;
}
//page template
$role = get_user_role();
if($role == "subscri... |
32,309 | <h3>The Call</h3>
<pre><code>$error = new WP_Error( $code, $message, $data );
</code></pre>
<h3>The Output</h3>
<p>Say I added three messages (msg A, msg B, msg C) to the code <code>my_code</code> and with the last message I added "Data" as <code>$data</code>, which overwrote all <code>$data</code> added with the pr... | [
{
"answer_id": 32313,
"author": "EarnestoDev",
"author_id": 8211,
"author_profile": "https://wordpress.stackexchange.com/users/8211",
"pm_score": 2,
"selected": false,
"text": "<p><code>$this->error_data[$code]</code> ... the WP_Error object holds $data in an array and $code is the ke... | 2011/10/28 | [
"https://wordpress.stackexchange.com/questions/32309",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/385/"
] | ### The Call
```
$error = new WP_Error( $code, $message, $data );
```
### The Output
Say I added three messages (msg A, msg B, msg C) to the code `my_code` and with the last message I added "Data" as `$data`, which overwrote all `$data` added with the previous calls to the error class.
```
WP_Error Object
(
[e... | `$this->error_data[$code]` ... the WP\_Error object holds $data in an array and $code is the key. The `add_data` method clearly states:
>
> The error code can only contain one error data. But the `$data` (mixed) can be an array or an object and carry as many keys/properties as you need. It's up to your handlers how ... |
32,310 | <p>this is my problem query, which picks all future or pending events.
<br>Note that some posts only have _startdate without _enddate (1-day events).</p>
<pre><code>$args = array(
'post_type'=> 'events',
'meta_query' => array(
array(
'key' => '_startdate',
'value' => $today,
'type' => ... | [
{
"answer_id": 32325,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": -1,
"selected": false,
"text": "<p>Replace <code>'meta_key'=> '_city'</code> with <code>'meta_key'=> '_startdate'</code>.</p>\n"
},
{
"... | 2011/10/28 | [
"https://wordpress.stackexchange.com/questions/32310",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9816/"
] | this is my problem query, which picks all future or pending events.
Note that some posts only have \_startdate without \_enddate (1-day events).
```
$args = array(
'post_type'=> 'events',
'meta_query' => array(
array(
'key' => '_startdate',
'value' => $today,
'type' => 'DATE',
'compare' => '>='
... | You could try
```
$args = array(
'post_type'=> 'events',
'meta_query' => array(
array(
'key' => '_startdate',
'value' => $today,
'compare' => '>=',
'type' => 'DATE',
),
array(
'key' => '_enddate',
'value' => $today,... |
32,320 | <p>I'm busy writing my first plugin, using PHP 5.3.5. I come from a C# environment, and I must say I'm more than happy with the level of support for good, solid OOP techniques in PHP. However, I'm a little uncertain how to structure a plugin using classes. I have a plugin class that takes care of hook registration in i... | [
{
"answer_id": 32324,
"author": "EarnestoDev",
"author_id": 8211,
"author_profile": "https://wordpress.stackexchange.com/users/8211",
"pm_score": 0,
"selected": false,
"text": "<pre><code>class Plugin{\n static public function Construct(){\n static $single_call = false; // Enab... | 2011/10/28 | [
"https://wordpress.stackexchange.com/questions/32320",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7268/"
] | I'm busy writing my first plugin, using PHP 5.3.5. I come from a C# environment, and I must say I'm more than happy with the level of support for good, solid OOP techniques in PHP. However, I'm a little uncertain how to structure a plugin using classes. I have a plugin class that takes care of hook registration in its ... | >
> I have one or two non-class scripts, mostly for forms, that I don't quite know how to neatly fit into classes.
>
>
>
Split your project into multiple classes. Keep your worker classes as instantiable objects (typical OOP patterns) and put your non-class scripts into a class of their own as static scripts.
I o... |
32,331 | <p>Everything on WordPress is primed for a production server, and hardly mentions info on development stuff.</p>
<p>I want to setup a WordPress blog locally so that its good and ready before it goes live. Are there any specific guidelines when setting up a local WordPress development environment.</p>
<p>What is the e... | [
{
"answer_id": 32346,
"author": "Fernando Briano",
"author_id": 298,
"author_profile": "https://wordpress.stackexchange.com/users/298",
"pm_score": 0,
"selected": false,
"text": "<p>When you say \"everything was fine\", what do you mean? Did you manage to get WordPress up and running on ... | 2011/10/28 | [
"https://wordpress.stackexchange.com/questions/32331",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9822/"
] | Everything on WordPress is primed for a production server, and hardly mentions info on development stuff.
I want to setup a WordPress blog locally so that its good and ready before it goes live. Are there any specific guidelines when setting up a local WordPress development environment.
What is the easiest way of cre... | WordPress local development environment:
========================================
Local development environments could apply to developing any type of application but there are some specific WordPress gotchas that could hinder your transition from local to dev.
The goal of a local development environment is to mimic ... |
32,337 | <p>I am displaying the attachments on the parent post page with this code : </p>
<pre><code> $args = array('post_type' => 'attachment', 'post_mime_type' => 'image', 'order'=> 'ASC', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID );
$attachments = get_posts($... | [
{
"answer_id": 32475,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/get_the_excerpt\" rel=\"noreferrer\"><code>get_the_excerpt()... | 2011/10/28 | [
"https://wordpress.stackexchange.com/questions/32337",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9749/"
] | I am displaying the attachments on the parent post page with this code :
```
$args = array('post_type' => 'attachment', 'post_mime_type' => 'image', 'order'=> 'ASC', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID );
$attachments = get_posts($args);
if ($attachments) {
... | [`get_the_excerpt()`](http://codex.wordpress.org/Function_Reference/get_the_excerpt) should work for getting caption just fine.
Your issue is that it looks for post to process in global variables and in your code there you are not setting it up with attachments you are iterating through.
You need to use [`setup_postd... |
32,347 | <p>My question is how to force the users that are auto-logged in because they previously checked "remember me" to log in again?</p>
<p>It may be something with cookies, but is there anything I can change/modify to do this ?</p>
<p>Thank you.</p>
<p><strong>UPDATE</strong></p>
<p>Generally, using jQuery cookie plugi... | [
{
"answer_id": 32350,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 0,
"selected": false,
"text": "<p>If you don't mind using a plugin this one will fix you up:\n<a href=\"http://wordpress.org/extend/plugins/i... | 2011/10/28 | [
"https://wordpress.stackexchange.com/questions/32347",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4448/"
] | My question is how to force the users that are auto-logged in because they previously checked "remember me" to log in again?
It may be something with cookies, but is there anything I can change/modify to do this ?
Thank you.
**UPDATE**
Generally, using jQuery cookie plugin, the code that checks for a cookie in user... | You can reset the security keys, forcing all cookies to expire and all users to log back in. Edit wp-config.php and change even one character in any of the security strings.
There's a plugin that allows you to set the expiry time on your user's cookies. I haven't personally used it, so proceed with caution: [Cookie Ti... |
32,356 | <p>I suddenly have a bug in my plugin, and I don't know what on earth could be causing it. This code is failing because <code>get_permalink()</code> is returning empty at all times:</p>
<pre><code>$select = "SELECT * FROM `".DB_NAME."`.`wp_posts` WHERE `post_status` = 'publish'";
$result = mysql_query($select);
while... | [
{
"answer_id": 32359,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 1,
"selected": false,
"text": "<p>First off, you should use <code>get_posts</code> instead of a raw SQL query. Or at least use <code>$wpdb... | 2011/10/28 | [
"https://wordpress.stackexchange.com/questions/32356",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7162/"
] | I suddenly have a bug in my plugin, and I don't know what on earth could be causing it. This code is failing because `get_permalink()` is returning empty at all times:
```
$select = "SELECT * FROM `".DB_NAME."`.`wp_posts` WHERE `post_status` = 'publish'";
$result = mysql_query($select);
while($meta_posts = mysql_fetch... | First off, you should use `get_posts` instead of a raw SQL query. Or at least use `$wpdb`.
```
<?php
$posts = get_posts(
array(
'post_status' => 'publish'
'numberposts' => -1
)
);
```
Then, try passing the entire post object to `get_permalink`, which [saves some database queries](http://yoast... |
32,357 | <p>This is probably a noob question BUT hear me out - isn't the point of using Nonce to protect from things like scrappers (phpcurl scrappers etc.)? But my Nonce prints out in the head of the document like so:</p>
<pre><code>/* <![CDATA[ */
var nc_ajax_getpost = {
...stuff...
getpostNonce: "8a3318a44c"
};
/... | [
{
"answer_id": 32361,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": 5,
"selected": true,
"text": "<p>Nonces are unique to each logged-in user. You can't scrape a logged-in user's nonces unless you have their cookies. ... | 2011/10/28 | [
"https://wordpress.stackexchange.com/questions/32357",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9830/"
] | This is probably a noob question BUT hear me out - isn't the point of using Nonce to protect from things like scrappers (phpcurl scrappers etc.)? But my Nonce prints out in the head of the document like so:
```
/* <![CDATA[ */
var nc_ajax_getpost = {
...stuff...
getpostNonce: "8a3318a44c"
};
/* ]]> */
```
So... | Nonces are unique to each logged-in user. You can't scrape a logged-in user's nonces unless you have their cookies. But if you have a user's cookies, you've already stolen their identity and can do whatever you want.
Nonces are meant to protect against users being tricked into doing something they didn't mean to do, b... |
32,377 | <p>I have a page that currently loads posts of custom post type using regular WP_Query. The custom post type are for news articles. Newer news articles (posts) are constantly written, as such there is a need for loading newer posts without having the user to refresh the page.</p>
<p>The effect I am desiring is similar... | [
{
"answer_id": 33663,
"author": "Dwayne Charrington",
"author_id": 1687,
"author_profile": "https://wordpress.stackexchange.com/users/1687",
"pm_score": 2,
"selected": true,
"text": "<p>I was in the same situation as you recently. The way I did it is probably wrong, and prone to bugs but... | 2011/10/29 | [
"https://wordpress.stackexchange.com/questions/32377",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9094/"
] | I have a page that currently loads posts of custom post type using regular WP\_Query. The custom post type are for news articles. Newer news articles (posts) are constantly written, as such there is a need for loading newer posts without having the user to refresh the page.
The effect I am desiring is similar to what ... | I was in the same situation as you recently. The way I did it is probably wrong, and prone to bugs but if you can live with that then this might help.
Basically you create an empty array at the top of your loop file, say for example loop-index.php.
$ignores = array();
Then inside your post loop you want to add these... |
32,380 | <p>I have alot of custom meta boxes, and the user has to scroll to the top everytime he wants to save the meta info. </p>
<p>Is there a way to put submit buttons at every meta box that does that same as the update button?</p>
| [
{
"answer_id": 32384,
"author": "EarnestoDev",
"author_id": 8211,
"author_profile": "https://wordpress.stackexchange.com/users/8211",
"pm_score": 2,
"selected": false,
"text": "<p><strong>DON'T DO IT!</strong>\nThere's reasons why FORMs have centralized submits. Because there's some proc... | 2011/10/29 | [
"https://wordpress.stackexchange.com/questions/32380",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9215/"
] | I have alot of custom meta boxes, and the user has to scroll to the top everytime he wants to save the meta info.
Is there a way to put submit buttons at every meta box that does that same as the update button? | Don't know if i agree with EarnestoDev answer which is more of an opinion then an answer based on facts and not true in all cases, since you can use jQuery to trigger
the submit event when a different element is clicked, so just add this js code once
```
<script>
jQuery('.metabox_submit').click(function(e) {
e.pr... |
32,388 | <p>Let's say you need to generate javascript or CSS code that depends on the current context. </p>
<p>For example you have a form on the homepage that fires an ajax request on submit, and a different form on the single page. Or in the case of CSS, you want to create a theme that allows its users to build their own lay... | [
{
"answer_id": 32393,
"author": "EarnestoDev",
"author_id": 8211,
"author_profile": "https://wordpress.stackexchange.com/users/8211",
"pm_score": -1,
"selected": false,
"text": "<p><strong>Create a dynamic JS.php file and feed important query_vars to it.</strong> Those variables in <code... | 2011/10/29 | [
"https://wordpress.stackexchange.com/questions/32388",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1986/"
] | Let's say you need to generate javascript or CSS code that depends on the current context.
For example you have a form on the homepage that fires an ajax request on submit, and a different form on the single page. Or in the case of CSS, you want to create a theme that allows its users to build their own layout, chang... | One additional option, depending on the kind of parameters you need to pass in. Let's call it (2a). You can also create PHP scripts which output dynamically-generated `text/css` or `text/javascript` rather than `text/html`, and provide them the data that they need using GET parameters rather than by loading up WordPres... |