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 |
|---|---|---|---|---|---|---|
101,928 | <p>I've written a custom function which works with the native WordPress custom fields function but I need it to work with the Advanced Custom Fields plugin.</p>
<p>I have created the custom field and meta box using the plugin and added the function to my child theme's <code>functions.php</code> file.</p>
<p>I am usin... | [
{
"answer_id": 101953,
"author": "Ashraf Slamang",
"author_id": 32069,
"author_profile": "https://wordpress.stackexchange.com/users/32069",
"pm_score": 1,
"selected": false,
"text": "<p>Any reason why you're using <code>genesis_custom_field()</code>? Advanced custom fields has its own ou... | 2013/06/05 | [
"https://wordpress.stackexchange.com/questions/101928",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29218/"
] | I've written a custom function which works with the native WordPress custom fields function but I need it to work with the Advanced Custom Fields plugin.
I have created the custom field and meta box using the plugin and added the function to my child theme's `functions.php` file.
I am using the field name (demo\_fiel... | Any reason why you're using `genesis_custom_field()`? Advanced custom fields has its own output functions. If you want to echo the `demo_field` you can use the function `the_field('demo_field');` or if you want to use the value or save it as a variable you can use `$demo = get_field('demo_field');`. |
101,931 | <p>I got to two loops in my template files. Both querying the same thing essentially.</p>
<p>This loop in my header:</p>
<pre><code>$testimonial_head = new WP_Query(array(
'posts_per_page' => 1,
'post_type' => 'testimonial',
'post_status' => 'published',
'orderby' => 'rand'
))... | [
{
"answer_id": 101938,
"author": "Rohit Pande",
"author_id": 21274,
"author_profile": "https://wordpress.stackexchange.com/users/21274",
"pm_score": 0,
"selected": false,
"text": "<p>\"<strong>Not a tested answer</strong>\":\nYou can try using a global variable in single template file. T... | 2013/06/05 | [
"https://wordpress.stackexchange.com/questions/101931",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11327/"
] | I got to two loops in my template files. Both querying the same thing essentially.
This loop in my header:
```
$testimonial_head = new WP_Query(array(
'posts_per_page' => 1,
'post_type' => 'testimonial',
'post_status' => 'published',
'orderby' => 'rand'
));
if ($testimonial_head->have_po... | Your two queries are identical, meaning you only need one of them. The basic solution is:
```
global $testimonials;
$testimonials = new WP_Query(array(
'posts_per_page' => 2, /* <-- get both */
'post_type' => 'testimonial',
'post_status' => 'published',
'orderby' => 'rand',
'ignore_sticky_p... |
101,942 | <p>I'm getting very confused trying to get an existing bit of code to work within a conditional if/else bit of code. I can't get the syntax correct. All the echo commas and semi colons (sorry I'm not a coder). </p>
<p>Existing code to show a post author info under the post content:</p>
<pre><code> <div id="auth... | [
{
"answer_id": 102052,
"author": "Szabolcs",
"author_id": 33461,
"author_profile": "https://wordpress.stackexchange.com/users/33461",
"pm_score": 0,
"selected": false,
"text": "<p>Finally this was solved by disabling some Jetpack modules. I am not sure which one did it, but I suspect th... | 2013/06/05 | [
"https://wordpress.stackexchange.com/questions/101942",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10147/"
] | I'm getting very confused trying to get an existing bit of code to work within a conditional if/else bit of code. I can't get the syntax correct. All the echo commas and semi colons (sorry I'm not a coder).
Existing code to show a post author info under the post content:
```
<div id="author-bio">
<h3>About ... | I just had the same problem using Jetpack v3.3 on <http://ataxproforyou.com>. I deactivated the whole jetpack plugin and the features came back, reactivated the plugin and was fine, until I connected it to my wordpress site <http://ataxproforyou.wordpress.com> and they went away again. I deactivated spell-check setting... |
101,951 | <p>In my WP site-- eg. <a href="http://www.mydomain.com--" rel="nofollow">http://www.mydomain.com--</a> a request has to be passed to a custom URL-- <a href="http://www.mydomain.com/custompage?param1=abc&param2=def" rel="nofollow">http://www.mydomain.com/custompage?param1=abc&param2=def</a></p>
<p>Now, I wish ... | [
{
"answer_id": 101955,
"author": "Matthew Boynes",
"author_id": 12324,
"author_profile": "https://wordpress.stackexchange.com/users/12324",
"pm_score": 2,
"selected": false,
"text": "<p>First, you register your query vars <code>param1</code> and <code>param2</code>:</p>\n\n<pre><code>fun... | 2013/06/05 | [
"https://wordpress.stackexchange.com/questions/101951",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19655/"
] | In my WP site-- eg. <http://www.mydomain.com--> a request has to be passed to a custom URL-- <http://www.mydomain.com/custompage?param1=abc¶m2=def>
Now, I wish to obtain the parameters passed to that URL from a function in functions.php of that theme. This function is executed when the above (example) URL is loade... | First, you register your query vars `param1` and `param2`:
```
function wpse_101951_query_vars( $qv ) {
$qv[] = 'param1';
$qv[] = 'param2';
return $qv;
}
add_filter( 'query_vars', 'wpse_101951_query_vars' );
```
To use this information, you can pretty much hook into any [action](http://codex.wordpress.or... |
101,952 | <p>The users have to be redirected to a custom URL which I already know (its part of the programming logic). I just need to know which WP function to use/ what php code to use to redirect the user to the new URL. This code will be executed within a php function in functions.php--> that function will first do some proce... | [
{
"answer_id": 101954,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 3,
"selected": false,
"text": "<p>First, it is hard to believe that <code>wp_redirect</code> isn't working, below some (example) code... | 2013/06/05 | [
"https://wordpress.stackexchange.com/questions/101952",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19655/"
] | The users have to be redirected to a custom URL which I already know (its part of the programming logic). I just need to know which WP function to use/ what php code to use to redirect the user to the new URL. This code will be executed within a php function in functions.php--> that function will first do some processi... | First, it is hard to believe that `wp_redirect` isn't working, below some (example) code how to use it:
```
function wpse101952_redirect() {
global $post;
if( /*SOME CONDITIONAL LOGIC*/ ) { //examples: is_home() or is_single() or is_user_logged_in() or isset($_SESSION['some_var'])
wp_redirect( /*SOME S... |
101,959 | <p>I want to pull all the children titles of certain page and put them as a link.
This is what i got so far: </p>
<pre><code>$my_wp_query = new WP_Query();
$all_wp_pages = $my_wp_query->query(array('post_type' => 'page'));
// Get the page as an Object
... | [
{
"answer_id": 101963,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>What you put doesn't make much sense, as it turns a 1 step action, into a 4 step action</p>\n\n<p>Why not ju... | 2013/06/05 | [
"https://wordpress.stackexchange.com/questions/101959",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33756/"
] | I want to pull all the children titles of certain page and put them as a link.
This is what i got so far:
```
$my_wp_query = new WP_Query();
$all_wp_pages = $my_wp_query->query(array('post_type' => 'page'));
// Get the page as an Object
$oferta = get_page_... | What you put doesn't make much sense, as it turns a 1 step action, into a 4 step action
Why not just put:
```
$oferta = get_page_by_title( 'Oferta' );
$my_query = new WP_Query( array(
'post_type' => 'page',
'post_parent' => $oferta->ID
) );
``` |
101,968 | <p>I want private posts (for those <em>not</em> logged in) to use the <code>single.php</code> template just as public posts do, at the moment they get thrown over to the <code>404.php</code> template.</p>
<p>I've had a good look through the core files but I cannot find where the template change (note: this is not a re... | [
{
"answer_id": 101977,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": false,
"text": "<p>According to the <a href=\"https://codex.wordpress.org/Content_Visibility#Private_Content\" rel=\"nofollow\">Co... | 2013/06/05 | [
"https://wordpress.stackexchange.com/questions/101968",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29/"
] | I want private posts (for those *not* logged in) to use the `single.php` template just as public posts do, at the moment they get thrown over to the `404.php` template.
I've had a good look through the core files but I cannot find where the template change (note: this is not a redirect) happens.
Can anyone help?
**E... | According to the [Content Visibility](https://codex.wordpress.org/Content_Visibility#Private_Content) page, Private posts are visible *only* to those with sufficient permission levels. WordPress doesn't expose them to non-logged-in users at all, hence (presumably) the `404`.
If you want to display a limited preview to... |
101,982 | <p>I'm pulling posts from Instagram into the WP basic archive view; but I want things to display in order of date, and not screw up paging (too much). The outcome should look like this:</p>
<p><strong>BLOG POST JUNE 4th</strong></p>
<p><em>INSTAGRAM IMAGE JUNE 3rd</em></p>
<p><em>INSTAGAM IMAGE JUNE 2nd</em></p>
<p... | [
{
"answer_id": 101987,
"author": "GhostToast",
"author_id": 13676,
"author_profile": "https://wordpress.stackexchange.com/users/13676",
"pm_score": 3,
"selected": true,
"text": "<p>Without knowing more about what your Instagram data feed object looks like, I would do something like this,... | 2013/06/05 | [
"https://wordpress.stackexchange.com/questions/101982",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3000/"
] | I'm pulling posts from Instagram into the WP basic archive view; but I want things to display in order of date, and not screw up paging (too much). The outcome should look like this:
**BLOG POST JUNE 4th**
*INSTAGRAM IMAGE JUNE 3rd*
*INSTAGAM IMAGE JUNE 2nd*
**BLOG POST JUNE 1st**
**BLOG POST MAY 20**
ETC
Is the... | Without knowing more about what your Instagram data feed object looks like, I would do something like this, assuming you already have a `$wp_query` object with *real* posts in it.
```
// we're going to merge both objects into one array so we can sort it
$merge_array = array();
// run through actual posts, assuming yo... |
101,993 | <p>How/Where is the <code>wp-admin/js/editor.min.js</code> file added to the backend WordPress post editing page (<code>wp-admin/post.php</code>)? How could I change this to use the non-minified file?</p>
<p>I'm working on a browser extension that will interact with a WordPress installation. I'd like to add some tem... | [
{
"answer_id": 101994,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>WordPress concatenates scripts via the <code>script-loader.php</code> file.</p>\n\n<p>You can disable the concatena... | 2013/06/05 | [
"https://wordpress.stackexchange.com/questions/101993",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33566/"
] | How/Where is the `wp-admin/js/editor.min.js` file added to the backend WordPress post editing page (`wp-admin/post.php`)? How could I change this to use the non-minified file?
I'm working on a browser extension that will interact with a WordPress installation. I'd like to add some temporary debugging code the the `edi... | WordPress concatenates scripts via the `script-loader.php` file.
You can disable the concatenation of scripts by adding this to your `wp-config.php`:
```
define('CONCATENATE_SCRIPTS', false);
```
You can load the non-minified versions by adding this to `wp-config.php`:
```
define('SCRIPT_DEBUG', true);
``` |
102,000 | <p>I've got the following code:</p>
<pre><code>function pietergoosen_persoonlike_kommentaar_velde($fields) {
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$fields = array(
'author' =>
'<p class="comme... | [
{
"answer_id": 101994,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>WordPress concatenates scripts via the <code>script-loader.php</code> file.</p>\n\n<p>You can disable the concatena... | 2013/06/05 | [
"https://wordpress.stackexchange.com/questions/102000",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31545/"
] | I've got the following code:
```
function pietergoosen_persoonlike_kommentaar_velde($fields) {
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$fields = array(
'author' =>
'<p class="comment-form-author"><lab... | WordPress concatenates scripts via the `script-loader.php` file.
You can disable the concatenation of scripts by adding this to your `wp-config.php`:
```
define('CONCATENATE_SCRIPTS', false);
```
You can load the non-minified versions by adding this to `wp-config.php`:
```
define('SCRIPT_DEBUG', true);
``` |
102,022 | <p>Currently my server instance is running wordpress (for example: <code>http://12.345.678.901</code>) if that were my ip once you hit that URL you would then get the index page. I'm going to move all this of course to a domain, and wasn't sure what I needed to change on the port over.</p>
<p>(I know about the Apache ... | [
{
"answer_id": 102023,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 2,
"selected": true,
"text": "<p>I always run queries in phpmyadmin <a href=\"http://www.phpmyadmin.net\" rel=\"nofollow\">http://www.phpmyadm... | 2013/06/06 | [
"https://wordpress.stackexchange.com/questions/102022",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15770/"
] | Currently my server instance is running wordpress (for example: `http://12.345.678.901`) if that were my ip once you hit that URL you would then get the index page. I'm going to move all this of course to a domain, and wasn't sure what I needed to change on the port over.
(I know about the Apache configs to point to t... | I always run queries in phpmyadmin <http://www.phpmyadmin.net> or adminer <http://www.adminer.org/>:
```
UPDATE wp_options SET option_value = replace(option_value, 'http://www.olddomain.com/', 'http://www.newdomain.com/') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, ... |
102,030 | <p>I'm stumped. I've looked at various sites but haven't found the exact code I need. </p>
<p>Basically I want to create a list of custom post titles with the date from one of the custom fields for that post along side.</p>
<p>So I'll end up with a list looking something like this:</p>
<p>Post Title 1 (with link) ..... | [
{
"answer_id": 102023,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 2,
"selected": true,
"text": "<p>I always run queries in phpmyadmin <a href=\"http://www.phpmyadmin.net\" rel=\"nofollow\">http://www.phpmyadm... | 2013/06/06 | [
"https://wordpress.stackexchange.com/questions/102030",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33782/"
] | I'm stumped. I've looked at various sites but haven't found the exact code I need.
Basically I want to create a list of custom post titles with the date from one of the custom fields for that post along side.
So I'll end up with a list looking something like this:
Post Title 1 (with link) ...... Associated Custom F... | I always run queries in phpmyadmin <http://www.phpmyadmin.net> or adminer <http://www.adminer.org/>:
```
UPDATE wp_options SET option_value = replace(option_value, 'http://www.olddomain.com/', 'http://www.newdomain.com/') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, ... |
102,043 | <p>I can't believe I did not find the right function for this:
I just want to retrieve the blog index url from a template.</p>
<p>My homepage is a static page. I am not looking for bloginfo('url') because it gives me my root url (/). I am looking for mysite.com/Blog</p>
<p>I am thinking about getting it via get_perma... | [
{
"answer_id": 102045,
"author": "Marc Dingena",
"author_id": 28660,
"author_profile": "https://wordpress.stackexchange.com/users/28660",
"pm_score": 0,
"selected": false,
"text": "<p><code><?php echo home_url(); ?></code> <-- Set in Settings > General > WordPress address</p>\n\... | 2013/06/06 | [
"https://wordpress.stackexchange.com/questions/102043",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15758/"
] | I can't believe I did not find the right function for this:
I just want to retrieve the blog index url from a template.
My homepage is a static page. I am not looking for bloginfo('url') because it gives me my root url (/). I am looking for mysite.com/Blog
I am thinking about getting it via get\_permalink($mypageid) ... | if you are referring to the 'posts page' as set under ***dashboard - settings - reading***:
```
<?php
if( get_option( 'page_for_posts' ) ) {
echo get_permalink( get_option( 'page_for_posts' ) );
} else {
echo home_url();
}
?>
``` |
102,063 | <p>Adding <code>die();</code> to the end of my ajax function file gives me totally blank page and this error in Firebug: </p>
<p><code>The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside... | [
{
"answer_id": 102045,
"author": "Marc Dingena",
"author_id": 28660,
"author_profile": "https://wordpress.stackexchange.com/users/28660",
"pm_score": 0,
"selected": false,
"text": "<p><code><?php echo home_url(); ?></code> <-- Set in Settings > General > WordPress address</p>\n\... | 2013/06/06 | [
"https://wordpress.stackexchange.com/questions/102063",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33230/"
] | Adding `die();` to the end of my ajax function file gives me totally blank page and this error in Firebug:
`The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The c... | if you are referring to the 'posts page' as set under ***dashboard - settings - reading***:
```
<?php
if( get_option( 'page_for_posts' ) ) {
echo get_permalink( get_option( 'page_for_posts' ) );
} else {
echo home_url();
}
?>
``` |
102,069 | <p>I have created search.php from Twenty Eleven theme search template. Search template works fine but i am having a problem when <b>no results are found</b>.
<br/><br/>I am getting this PHP Notice: <b><i>Notice: Trying to get property of non-object wp-includes/post-template.php on line 29</i></b></p>
<p>Post-template... | [
{
"answer_id": 102078,
"author": "Svetlana Silina",
"author_id": 33680,
"author_profile": "https://wordpress.stackexchange.com/users/33680",
"pm_score": 2,
"selected": true,
"text": "<p>get_post() returns the post object to the loop. So when you look for its ->ID if no object is there yo... | 2013/06/06 | [
"https://wordpress.stackexchange.com/questions/102069",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20941/"
] | I have created search.php from Twenty Eleven theme search template. Search template works fine but i am having a problem when **no results are found**.
I am getting this PHP Notice: ***Notice: Trying to get property of non-object wp-includes/post-template.php on line 29***
Post-template line 29 looks like this:
```
... | get\_post() returns the post object to the loop. So when you look for its ->ID if no object is there you try to make php to look for ID of nothing, and it gives you the notice. Change post->ID for
```
if( ! get_post() )
``` |
102,071 | <p>Is there an easy way to delete all transient caches? A plugin maybe? Or like in drupal "drush cc all"?</p>
| [
{
"answer_id": 102074,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 2,
"selected": false,
"text": "<p>Not tested, but if you need a quick and dirty way, you could put a script like this in your WordPress folder ... | 2013/06/06 | [
"https://wordpress.stackexchange.com/questions/102071",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33797/"
] | Is there an easy way to delete all transient caches? A plugin maybe? Or like in drupal "drush cc all"? | Install <https://wp-cli.org/> and use the command
```
wp transient delete --all
``` |
102,079 | <p>How can I replace wp_get_attachment_image() function without changing the core files. The function doesnt have an action hook or a filter hook. </p>
<p><strong>What I am trying to achieve:</strong></p>
<p>for lazyload plugin output the image html like this:</p>
<pre><code><img width="150" height="150" data-src... | [
{
"answer_id": 102083,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 0,
"selected": false,
"text": "<p>You can create another function in your <code>functions.php</code> file and then use it instead of <code>wp_g... | 2013/06/06 | [
"https://wordpress.stackexchange.com/questions/102079",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1905/"
] | How can I replace wp\_get\_attachment\_image() function without changing the core files. The function doesnt have an action hook or a filter hook.
**What I am trying to achieve:**
for lazyload plugin output the image html like this:
```
<img width="150" height="150" data-src="http://localhost/yxz/wp-content/uploads... | There is a filter, [`wp_get_attachment_image_attributes`](http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/media.php#L565), for the image attributes-- a well designed one too.
```
function alter_att_attributes_wpse_102079($attr) {
$attr['data-src'] = $attr['src'];
return $attr;
}
add_filter( 'wp_get_a... |
102,127 | <p>I'm doing some de-bugging on a theme I'm working on and I'm hoping someone can help me please.</p>
<p>I used this function that Justin Tadlock made to display custom post types on the blog page and with wp-debug set to true I get a Notice: Undefined index: suppress_filters message.</p>
<p>The code is as follows:</... | [
{
"answer_id": 102131,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>If <code>$query->query_vars['suppress_filters']</code> is not set you will get that message.</p>\n\n<p>Use... | 2013/06/06 | [
"https://wordpress.stackexchange.com/questions/102127",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33243/"
] | I'm doing some de-bugging on a theme I'm working on and I'm hoping someone can help me please.
I used this function that Justin Tadlock made to display custom post types on the blog page and with wp-debug set to true I get a Notice: Undefined index: suppress\_filters message.
The code is as follows:
```
// Custom Po... | If `$query->query_vars['suppress_filters']` is not set you will get that message.
Use `empty($query->query_vars['suppress_filters'])` instead of `false == $query->query_vars['suppress_filters'] )` or use `$query->get('suppress_filters')` like this `false == $query->get('suppress_filters')`.
Untested (minimally tested... |
102,139 | <p>Found this code in the WP Codex but not sure how to use it to remove the hyperlink and/or date from comments.</p>
<pre><code>delete_comment_meta( $comment_id, $meta_key, $meta_value );
</code></pre>
| [
{
"answer_id": 102131,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>If <code>$query->query_vars['suppress_filters']</code> is not set you will get that message.</p>\n\n<p>Use... | 2013/06/06 | [
"https://wordpress.stackexchange.com/questions/102139",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29218/"
] | Found this code in the WP Codex but not sure how to use it to remove the hyperlink and/or date from comments.
```
delete_comment_meta( $comment_id, $meta_key, $meta_value );
``` | If `$query->query_vars['suppress_filters']` is not set you will get that message.
Use `empty($query->query_vars['suppress_filters'])` instead of `false == $query->query_vars['suppress_filters'] )` or use `$query->get('suppress_filters')` like this `false == $query->get('suppress_filters')`.
Untested (minimally tested... |
102,152 | <p>Here's how I define the CPT:</p>
<pre><code>$args = array(
'labels' => $labels,
'public' => FALSE,
'show_ui' => TRUE,
'capability_type' => SNG_CAP_SUPPORT,
'hierarchical' => FALSE,
'supports' => array(
'title',
'editor'
... | [
{
"answer_id": 102156,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>This is a known bug: <a href=\"http://core.trac.wordpress.org/ticket/17609\" rel=\"nofollow\">#17609 'View post' link... | 2013/06/06 | [
"https://wordpress.stackexchange.com/questions/102152",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14064/"
] | Here's how I define the CPT:
```
$args = array(
'labels' => $labels,
'public' => FALSE,
'show_ui' => TRUE,
'capability_type' => SNG_CAP_SUPPORT,
'hierarchical' => FALSE,
'supports' => array(
'title',
'editor'
),
'menu_icon' => SNG... | I think that at least part of what you want is to [alter the submission update messages](http://core.trac.wordpress.org/browser/tags/3.5.1/wp-admin/edit-form-advanced.php#L33), probably in addition to @toscho's code.
```
function kill_message($messages) {
global $post_type;
// var_dump($messages); die;
if ('your... |
102,158 | <p>I'm using post thumbnails to link to a page.</p>
<p>Is it possible to add a class name to the post thumbnail image.</p>
<pre><code><li><a href="<?php the_permalink(); ?>" ><?php the_post_thumbnail(); ?></a></li>
</code></pre>
| [
{
"answer_id": 102159,
"author": "sabreuse",
"author_id": 2140,
"author_profile": "https://wordpress.stackexchange.com/users/2140",
"pm_score": 7,
"selected": true,
"text": "<p>Yep - you can pass the class you want to use to <code>the_post_thumbnail()</code> as part of the attributes arg... | 2013/06/06 | [
"https://wordpress.stackexchange.com/questions/102158",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31546/"
] | I'm using post thumbnails to link to a page.
Is it possible to add a class name to the post thumbnail image.
```
<li><a href="<?php the_permalink(); ?>" ><?php the_post_thumbnail(); ?></a></li>
``` | Yep - you can pass the class you want to use to `the_post_thumbnail()` as part of the attributes argument, for example `<?php the_post_thumbnail('thumbnail', array('class' => 'your-class-name')); ?>`
Ref: <http://codex.wordpress.org/Function_Reference/the_post_thumbnail#Styling_Post_Thumbnails> |
102,181 | <p>I'd like to add next and previous post links on single posts which use a custom post type. Prefer links only work for the posts assigned to the custom post type.</p>
<p>How would i add it to this:</p>
<pre><code>function wpsites_npp_navigation_links() {
if( 'portfolio_post_type' == get_post_type() ) {?>
<?ph... | [
{
"answer_id": 102182,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>A simple solution is to edit your <code>single.php</code> template file and wrap the calls to previous and next po... | 2013/06/07 | [
"https://wordpress.stackexchange.com/questions/102181",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29218/"
] | I'd like to add next and previous post links on single posts which use a custom post type. Prefer links only work for the posts assigned to the custom post type.
How would i add it to this:
```
function wpsites_npp_navigation_links() {
if( 'portfolio_post_type' == get_post_type() ) {?>
<?php previous_post('« &l... | A simple solution is to edit your `single.php` template file and wrap the calls to previous and next post link with a check of the post type:
```
if( 'your_post_type' == get_post_type() ) {
previous_post_link();
next_post_link();
}
``` |
102,209 | <p>I want wrap all default widget into a div tag, so i can add a suffix class to define style for each widgets</p>
<pre><code><div class="suffix-class">
// widget
</div>
</code></pre>
<p>And in widget form, we have a input field to input this class.</p>
<p>It like module of joomla.</p>
<p>What can we d... | [
{
"answer_id": 116077,
"author": "starter",
"author_id": 38768,
"author_profile": "https://wordpress.stackexchange.com/users/38768",
"pm_score": 0,
"selected": false,
"text": "<p>I see this uestion is kind of old, but it also doesn't seem to have been answered. For anyone who wants to do... | 2013/06/07 | [
"https://wordpress.stackexchange.com/questions/102209",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48231/"
] | I want wrap all default widget into a div tag, so i can add a suffix class to define style for each widgets
```
<div class="suffix-class">
// widget
</div>
```
And in widget form, we have a input field to input this class.
It like module of joomla.
What can we do ? override all default widget ? | In the [`register_sidebar()`](https://codex.wordpress.org/Function_Reference/register_sidebars) call in `functions.php`.
Look for `before_widget` and `after_widget` and modify as appropriate. The code below is the default usage.
```
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
... |
102,210 | <p>I have a page where I show all the attachments of a page in a table which has <code>id=10</code>.</p>
<p>I have hundreds of attachments and I would like to implement an AJAX search form that uses the title of attachment as key for search.</p>
<p>Actually the problem is not in implementing the AJAX call, but the qu... | [
{
"answer_id": 116077,
"author": "starter",
"author_id": 38768,
"author_profile": "https://wordpress.stackexchange.com/users/38768",
"pm_score": 0,
"selected": false,
"text": "<p>I see this uestion is kind of old, but it also doesn't seem to have been answered. For anyone who wants to do... | 2013/06/07 | [
"https://wordpress.stackexchange.com/questions/102210",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17815/"
] | I have a page where I show all the attachments of a page in a table which has `id=10`.
I have hundreds of attachments and I would like to implement an AJAX search form that uses the title of attachment as key for search.
Actually the problem is not in implementing the AJAX call, but the query that returns the attachm... | In the [`register_sidebar()`](https://codex.wordpress.org/Function_Reference/register_sidebars) call in `functions.php`.
Look for `before_widget` and `after_widget` and modify as appropriate. The code below is the default usage.
```
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
... |
102,214 | <p><strong>The Issue:</strong> I am looking for <em>custom</em> single post templates, to add or remove individual elements as a function of a normal single post.</p>
<p>There are a lot of ways to create custom post templates for single posts within WordPress. Especially post formats are a great chance to use <em>defa... | [
{
"answer_id": 102224,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 2,
"selected": false,
"text": "<p>I think this approach will work.</p>\n\n<p>1.create template for single post like <code>singlepost.php... | 2013/06/07 | [
"https://wordpress.stackexchange.com/questions/102214",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32946/"
] | **The Issue:** I am looking for *custom* single post templates, to add or remove individual elements as a function of a normal single post.
There are a lot of ways to create custom post templates for single posts within WordPress. Especially post formats are a great chance to use *default* templates for default cases;... | This is finally possible with WordPress 4.4 (as announced on [Make WordPress Core](https://make.wordpress.org/core/2015/10/07/single-post_type-post_name-php-new-theme-template-in-wordpress-4-4/)).
The WordPress [template hierarchy](https://developer.wordpress.org/themes/basics/template-hierarchy/) now allows *single c... |
102,225 | <p>I need to create a search box in my default searchform.php file that has similar behaviour as the default ability in HTML5 with the "placeholder" attribute.</p>
<p>This is what I have in my searchform.php at the moment:</p>
<pre><code> <input type="submit" id="searchsubmit" value="text" />
<input placeho... | [
{
"answer_id": 102228,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 3,
"selected": true,
"text": "<p>Placeholder by itself will not disappear when you click the text field. I guess you need a bit of Javascript t... | 2013/06/07 | [
"https://wordpress.stackexchange.com/questions/102225",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21403/"
] | I need to create a search box in my default searchform.php file that has similar behaviour as the default ability in HTML5 with the "placeholder" attribute.
This is what I have in my searchform.php at the moment:
```
<input type="submit" id="searchsubmit" value="text" />
<input placeholder="<?php _e( 'Search here..... | Placeholder by itself will not disappear when you click the text field. I guess you need a bit of Javascript to achieve that.
```
<input type="text" onfocus="if(this.value=='<?php _e( 'Search here..' ); ?>'){this.value='';}" onblur="if(this.value==''){this.value='<?php _e( 'Search here..' ); ?>';}" value="<?php _e( 'S... |
102,249 | <p>I'm trying to add a "share this" button to my site. I am having an issue configure this because when I go to settings -> sharing I get the image below<img src="https://i.stack.imgur.com/CXS2W.png" alt="enter image description here"></p>
<p>Update: Here is my inspector error console:<img src="https://i.stack.imgur.c... | [
{
"answer_id": 102251,
"author": "GhostToast",
"author_id": 13676,
"author_profile": "https://wordpress.stackexchange.com/users/13676",
"pm_score": 0,
"selected": false,
"text": "<p>Something is wrong with your jetpack. Try disabling other plugins, or uninstalling and reinstalling jetpac... | 2013/06/07 | [
"https://wordpress.stackexchange.com/questions/102249",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30778/"
] | I'm trying to add a "share this" button to my site. I am having an issue configure this because when I go to settings -> sharing I get the image below
Update: Here is my inspector error console: from any gallery / attachment and then displaying it with wp_get_attachment_image().</p>
<p>Here is my code:</p>
<pre><code>if ( $images ) {
foreach ( $images as $image ) {
echo '<li>';
echo wp_get_attachment_image( $images, 'thum... | [
{
"answer_id": 102258,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 1,
"selected": false,
"text": "<p>Really everything you need to know is in the docs. See <a href=\"http://codex.wordpress.org/Moving_WordPress... | 2013/06/07 | [
"https://wordpress.stackexchange.com/questions/102272",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18447/"
] | I'd like the client to be able to type any image ID (number) from any gallery / attachment and then displaying it with wp\_get\_attachment\_image().
Here is my code:
```
if ( $images ) {
foreach ( $images as $image ) {
echo '<li>';
echo wp_get_attachment_image( $images, 'thumbnail' ); // notice this... | Really everything you need to know is in the docs. See [Moving WordPress « WordPress Codex.](http://codex.wordpress.org/Moving_WordPress)
They cover exporting/importing databases, moving uploads and other content, themes, etc.
For particular issues with moving WP installs, search this site; many have already been ans... |
102,279 | <p>I'm using the <a href="http://wordpress.org/plugins/events-manager/" rel="noreferrer">events manager plugin</a> to create custom posts for events. I do not have a need for a blog, so I modified my theme's <code>index.php</code> file (using a child theme) for its query to retrieve the "event" post type on the home pa... | [
{
"answer_id": 102282,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>It sounds like you need a <code>meta_query</code>.</p>\n<pre><code>$query = new WP_Query ( \n array( \n ... | 2013/06/07 | [
"https://wordpress.stackexchange.com/questions/102279",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22510/"
] | I'm using the [events manager plugin](http://wordpress.org/plugins/events-manager/) to create custom posts for events. I do not have a need for a blog, so I modified my theme's `index.php` file (using a child theme) for its query to retrieve the "event" post type on the home page.
`new WP_Query ( array( 'paged' => $p... | Copied from [StackOverflow](https://stackoverflow.com/a/29279530/209859):
>
> `WP_Query` offers a `date_query` parameter, allowing you to set a range with before and after.
>
>
> <https://developer.wordpress.org/reference/classes/wp_query/#date-parameters>
>
>
>
```php
$args = array(
'date_query' => array(
... |
102,288 | <p>I am using the Advanced Custom Field Plugin to add custom fields for the users profiles and display a list of users in the frontend of site with Simple User Listing Plugin.</p>
<p>I need to filter a list of users by a custom search through some options: city, neighborhood and course university.</p>
<p>See an examp... | [
{
"answer_id": 102282,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>It sounds like you need a <code>meta_query</code>.</p>\n<pre><code>$query = new WP_Query ( \n array( \n ... | 2013/06/07 | [
"https://wordpress.stackexchange.com/questions/102288",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32422/"
] | I am using the Advanced Custom Field Plugin to add custom fields for the users profiles and display a list of users in the frontend of site with Simple User Listing Plugin.
I need to filter a list of users by a custom search through some options: city, neighborhood and course university.
See an example of how it is b... | Copied from [StackOverflow](https://stackoverflow.com/a/29279530/209859):
>
> `WP_Query` offers a `date_query` parameter, allowing you to set a range with before and after.
>
>
> <https://developer.wordpress.org/reference/classes/wp_query/#date-parameters>
>
>
>
```php
$args = array(
'date_query' => array(
... |
102,289 | <p>I am using WordPress 3.5.1 / Twenty Twelve Theme.
I would like to display a custom field in my Category Archives.
I have the following custom field working in my single.php , it displays a custom url / title</p>
<pre><code><a href="http://<?php echo get_post_meta($post->ID, "user_submit_url", true); ?>"... | [
{
"answer_id": 102293,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<p>If your Loop is constructed correctly <code>$post</code> will be set for each post in the loop in turn. You c... | 2013/06/07 | [
"https://wordpress.stackexchange.com/questions/102289",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33866/"
] | I am using WordPress 3.5.1 / Twenty Twelve Theme.
I would like to display a custom field in my Category Archives.
I have the following custom field working in my single.php , it displays a custom url / title
```
<a href="http://<?php echo get_post_meta($post->ID, "user_submit_url", true); ?>" target="_blank"> <h1 cla... | If your Loop is constructed correctly `$post` will be set for each post in the loop in turn. You could also consider using [`get_the_ID`](http://codex.wordpress.org/Function_Reference/get_the_ID).
`get_post_meta($post->ID, "user_submit_url", true);` by itself won't do much. You will have to format and `echo` the infor... |
102,304 | <p>I want visitors who have typed <code>site.com</code>, stay on <code>site.com</code> and visitors who have come to <code>site.net</code>, stay at <code>site.net</code> (They have one host and <code>site.net</code> has been parked on <code>.com</code>).</p>
<p>When it comes to search engines, because of SEO they shou... | [
{
"answer_id": 102312,
"author": "a web dev",
"author_id": 33840,
"author_profile": "https://wordpress.stackexchange.com/users/33840",
"pm_score": 2,
"selected": true,
"text": "<p>Canonical links are typically used when you have multiple URLs on the <strong>same domain</strong> pointed a... | 2013/06/08 | [
"https://wordpress.stackexchange.com/questions/102304",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27790/"
] | I want visitors who have typed `site.com`, stay on `site.com` and visitors who have come to `site.net`, stay at `site.net` (They have one host and `site.net` has been parked on `.com`).
When it comes to search engines, because of SEO they should understand that the both domain are locating to the same host. I know tha... | Canonical links are typically used when you have multiple URLs on the **same domain** pointed at the **same content** to prevent search engines from indexing duplicate content.
In this case, redirecting the domain is probably the best option.
You can do that either through the control panel for your domains or with a... |
102,313 | <p>How to update post date of page to real time when Visitor access that page?</p>
<p>Example: I write a post on May 28, 2013. And now, when I visit that post, it will change may 28 to June 8.</p>
<p>How to do this?</p>
| [
{
"answer_id": 102317,
"author": "Suvajit Pal",
"author_id": 33873,
"author_profile": "https://wordpress.stackexchange.com/users/33873",
"pm_score": 0,
"selected": false,
"text": "<p>You could use wp_update_post in your page template or php page you are using to view the page to update t... | 2013/06/08 | [
"https://wordpress.stackexchange.com/questions/102313",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33555/"
] | How to update post date of page to real time when Visitor access that page?
Example: I write a post on May 28, 2013. And now, when I visit that post, it will change may 28 to June 8.
How to do this? | You can hook into the action `the_post` (you get the post as parameter here) and run `wp_update_post()`. Make sure to clean up the *date* properties and not to run on the admin side or when a post is called in a widget:
```
is_admin() or add_action( 'the_post', function( $post ) {
if ( ! is_singular() or ! is_mai... |
102,346 | <p>I am using the following code to display a random post from the current category in category archive page (using archive.php). However, when in Tag or Taxonomy archive pages, the post is not correctly displayed from the current Tag or Taxonomy (due to the limitation of category only). How can I modify to make it wor... | [
{
"answer_id": 102348,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 1,
"selected": false,
"text": "<p>You could consider using the main query with a custom <code>pre_get_posts</code> hook:</p>\n\n<pre><code>add_... | 2013/06/08 | [
"https://wordpress.stackexchange.com/questions/102346",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10174/"
] | I am using the following code to display a random post from the current category in category archive page (using archive.php). However, when in Tag or Taxonomy archive pages, the post is not correctly displayed from the current Tag or Taxonomy (due to the limitation of category only). How can I modify to make it work w... | You will need to grab the queried object for the page and fill in your taxonomy information dynamically.
```
if (is_tax() || is_category() || is_tag() ){
$qobj = get_queried_object();
// var_dump($qobj); // debugging only
// concatenate the query
$args = array(
'posts_per_page' => 1,
'orde... |
102,349 | <p>I have a csv file that I want to insert that consists of ~1,500 rows and 97 columns. It takes about 2-3 hours to do a full import and I'd like to improve this if there is a way. Currently for each row I'm doing a $post_id = wp_insert_post and then an add_post_meta for the 97 associated columns with each row. This i... | [
{
"answer_id": 102354,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": false,
"text": "<p>You will need to insert the post to get your ID but the <code>$wpdb->postmeta</code> table is very simple... | 2013/06/08 | [
"https://wordpress.stackexchange.com/questions/102349",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33883/"
] | I have a csv file that I want to insert that consists of ~1,500 rows and 97 columns. It takes about 2-3 hours to do a full import and I'd like to improve this if there is a way. Currently for each row I'm doing a $post\_id = wp\_insert\_post and then an add\_post\_meta for the 97 associated columns with each row. This ... | I had similar problems sometime ago with a custom CSV import, but I ended up by using some custom SQL for the bulk insert. But I hadn't seen this answer by then:
[Optimize post insert and delete for bulk operations?](https://wordpress.stackexchange.com/questions/9624/optimize-post-insert-and-delete-for-bulk-operations... |
102,363 | <p>I'm seeing that a lot of sites (moz.com,hubspot.com) are using a background image as a layout. How do I add a single background image easily onto WordPress? I also want to add the layout here: <a href="http://moz.com/blog" rel="nofollow">http://moz.com/blog</a> onto my blog. How do I do this?</p>
| [
{
"answer_id": 102366,
"author": "iyrin",
"author_id": 33393,
"author_profile": "https://wordpress.stackexchange.com/users/33393",
"pm_score": 1,
"selected": true,
"text": "<p>This assumes that you want to add a background image for a specific page:</p>\n\n<p>Create your CSS class for th... | 2013/06/08 | [
"https://wordpress.stackexchange.com/questions/102363",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33728/"
] | I'm seeing that a lot of sites (moz.com,hubspot.com) are using a background image as a layout. How do I add a single background image easily onto WordPress? I also want to add the layout here: <http://moz.com/blog> onto my blog. How do I do this? | This assumes that you want to add a background image for a specific page:
Create your CSS class for the background you want.
```
body.custombg {background: url("images/background.gif"); }
```
In the header, you can use something like this to check for a specific page.
```
<body <?php if(is_page(123)) echo 'class="... |
102,368 | <p>I have been trying to add new wordpress roles and capabilities, in a multisite installation, using the code below. The issue is, it only applies to the 'main' site of the multisite, and does not propogate to the subsites. I haven't really found anything in the documentation that covers this.</p>
<pre><code>function... | [
{
"answer_id": 102366,
"author": "iyrin",
"author_id": 33393,
"author_profile": "https://wordpress.stackexchange.com/users/33393",
"pm_score": 1,
"selected": true,
"text": "<p>This assumes that you want to add a background image for a specific page:</p>\n\n<p>Create your CSS class for th... | 2013/06/08 | [
"https://wordpress.stackexchange.com/questions/102368",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12840/"
] | I have been trying to add new wordpress roles and capabilities, in a multisite installation, using the code below. The issue is, it only applies to the 'main' site of the multisite, and does not propogate to the subsites. I haven't really found anything in the documentation that covers this.
```
function civicrm_wp_se... | This assumes that you want to add a background image for a specific page:
Create your CSS class for the background you want.
```
body.custombg {background: url("images/background.gif"); }
```
In the header, you can use something like this to check for a specific page.
```
<body <?php if(is_page(123)) echo 'class="... |
102,369 | <p>I noticed that WordPress files use UNIX end-of-line and UTF-8 without BOM. Is this a standard that should be used? Is there anything else to pay attention to?</p>
<p>I noticed that Filezilla fails to transfer Macintosh end-of-line files properly to Windows or Linux servers. New line endings are missing. And sometim... | [
{
"answer_id": 102380,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>UNIX line endings (<code>\\n</code>) and UTF-8 are just common code standards. As far as I can see, they are not even ... | 2013/06/08 | [
"https://wordpress.stackexchange.com/questions/102369",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17167/"
] | I noticed that WordPress files use UNIX end-of-line and UTF-8 without BOM. Is this a standard that should be used? Is there anything else to pay attention to?
I noticed that Filezilla fails to transfer Macintosh end-of-line files properly to Windows or Linux servers. New line endings are missing. And sometimes they ar... | UNIX line endings (`\n`) and UTF-8 are just common code standards. As far as I can see, they are not even mentioned in the [Coding Standards](http://make.wordpress.org/core/handbook/coding-standards/php/). Most (all?) core PHP files are just plain US-ASCII. Try to follow that path to keep your files as compatible as po... |
102,386 | <p>I want to use WP-CLI to create some new posts with custom taxonomy terms assigned. The challenge is that wp_insert_post's <code>tax_input</code> argument only accepts arrays, which I would have to specify on the command line. According to the <a href="http://codex.wordpress.org/Function_Reference/wp_insert_post" rel... | [
{
"answer_id": 110180,
"author": "tungd",
"author_id": 20178,
"author_profile": "https://wordpress.stackexchange.com/users/20178",
"pm_score": 2,
"selected": false,
"text": "<p>This is probably impossible since WP-CLI pass the arguments directly to <code>wp_insert_posts</code>. I'm autom... | 2013/06/09 | [
"https://wordpress.stackexchange.com/questions/102386",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33075/"
] | I want to use WP-CLI to create some new posts with custom taxonomy terms assigned. The challenge is that wp\_insert\_post's `tax_input` argument only accepts arrays, which I would have to specify on the command line. According to the [codex](http://codex.wordpress.org/Function_Reference/wp_insert_post), here is the for... | This is probably impossible since WP-CLI pass the arguments directly to `wp_insert_posts`. I'm automating this with `wp eval`. For example:
```
wp eval 'wp_set_object_terms(12 , array(1, 2, 3), "course");'
```
The post id can be obtained when you create the post with `--porcelain`:
```
wp post create ... --porcelai... |
102,401 | <p>I am editing the sidebar widgets and have added one for users who are not logged in or registered. the widget requests that users register or login and I am wanting to add a random reason (quote) as to why they should join which will change after every reload of the page.</p>
<p>I have chosen to use the "text" in t... | [
{
"answer_id": 102405,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>You say that you are...</p>\n\n<blockquote>\n <p>... wanting to add a random reason (quote) as to why they ... | 2013/06/09 | [
"https://wordpress.stackexchange.com/questions/102401",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26975/"
] | I am editing the sidebar widgets and have added one for users who are not logged in or registered. the widget requests that users register or login and I am wanting to add a random reason (quote) as to why they should join which will change after every reload of the page.
I have chosen to use the "text" in the site wh... | You say that you are...
>
> ... wanting to add a random reason (quote) as to why they should join
> which will change after every reload of the page
>
>
>
And you seem to trying to do this by placing Javascript in a text widget. I assume that is what you mean by the '"text" in the site'.
Based on that descripti... |
102,404 | <p>I have a custom post type for which I have created a custom taxonomy called 'tag'. <code>taxonomy-tag.php</code> file looks like this:</p>
<pre><code><?php get_header(); ?>
<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); ?>
<h1 class="page-title">... | [
{
"answer_id": 102406,
"author": "whiteletters in blankpapers",
"author_id": 16048,
"author_profile": "https://wordpress.stackexchange.com/users/16048",
"pm_score": 1,
"selected": true,
"text": "<p><strong>Solution:</strong></p>\n\n<p>At the beginning I thought I resolved my problem afte... | 2013/06/09 | [
"https://wordpress.stackexchange.com/questions/102404",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16048/"
] | I have a custom post type for which I have created a custom taxonomy called 'tag'. `taxonomy-tag.php` file looks like this:
```
<?php get_header(); ?>
<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); ?>
<h1 class="page-title"><?php echo $term->name; ?> Archives</h1>
... | **Solution:**
At the beginning I thought I resolved my problem after creating a new query with the arguments I need. The code I added is:
```
<?php
$args = array(
'paged' => $paged,
'post_type' => 'post_type_name',
'tax_query' => array(
array('taxonomy' => 'tag','terms' => $term->t... |
102,413 | <p>I'm working on a theme that requires the end-user to specify the current performance season using a custom admin panel I've created, ie. "2013/2014", "2014/2015" etc., which I can retrieve using <code>get_option('current_season');</code></p>
<p>On my custom nav menu I have a page titled "Season" that needs the afor... | [
{
"answer_id": 102406,
"author": "whiteletters in blankpapers",
"author_id": 16048,
"author_profile": "https://wordpress.stackexchange.com/users/16048",
"pm_score": 1,
"selected": true,
"text": "<p><strong>Solution:</strong></p>\n\n<p>At the beginning I thought I resolved my problem afte... | 2013/06/09 | [
"https://wordpress.stackexchange.com/questions/102413",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33907/"
] | I'm working on a theme that requires the end-user to specify the current performance season using a custom admin panel I've created, ie. "2013/2014", "2014/2015" etc., which I can retrieve using `get_option('current_season');`
On my custom nav menu I have a page titled "Season" that needs the aforementioned field inse... | **Solution:**
At the beginning I thought I resolved my problem after creating a new query with the arguments I need. The code I added is:
```
<?php
$args = array(
'paged' => $paged,
'post_type' => 'post_type_name',
'tax_query' => array(
array('taxonomy' => 'tag','terms' => $term->t... |
102,447 | <p>I've been modifying the built in WP search using the <code>pre_get_posts</code> filter, allowing the user to sort the posts (including a bunch of custom post types) by different fields.</p>
<p>The problem I'm having though is that when I tell WP to sort by a meta value it will exclude all posts that don't have that... | [
{
"answer_id": 102453,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>There's a possible <code>orderby</code> value of <code>meta_value</code> for that.</p>\n\n<pre><code>$query = new ... | 2013/06/09 | [
"https://wordpress.stackexchange.com/questions/102447",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23714/"
] | I've been modifying the built in WP search using the `pre_get_posts` filter, allowing the user to sort the posts (including a bunch of custom post types) by different fields.
The problem I'm having though is that when I tell WP to sort by a meta value it will exclude all posts that don't have that meta value set. This... | There's two possible solutions to this:
1. All posts have meta
----------------------
The best solution I have found here is to give the rest of the posts/products an item price of 0. You can do this manually, or loop through all the posts and if the price is empty then update it.
To make this manageable in the futu... |
102,466 | <p>im creating wordpress user using <code>wp_create_user()</code> function and when user creating i want to add that users userid to custom table,</p>
<p>this is the way i tried</p>
<pre><code>add_action( 'user_register', 'atuser_info');
function atuser_info( $user_id ) {
global $wpdb;
//$prefix=$w... | [
{
"answer_id": 102453,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>There's a possible <code>orderby</code> value of <code>meta_value</code> for that.</p>\n\n<pre><code>$query = new ... | 2013/06/10 | [
"https://wordpress.stackexchange.com/questions/102466",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28855/"
] | im creating wordpress user using `wp_create_user()` function and when user creating i want to add that users userid to custom table,
this is the way i tried
```
add_action( 'user_register', 'atuser_info');
function atuser_info( $user_id ) {
global $wpdb;
//$prefix=$wpdb->prefix;
... | There's two possible solutions to this:
1. All posts have meta
----------------------
The best solution I have found here is to give the rest of the posts/products an item price of 0. You can do this manually, or loop through all the posts and if the price is empty then update it.
To make this manageable in the futu... |
102,480 | <p>I want to create a page that can be embedded in other sites with an embed script like this:</p>
<pre><code><iframe src="http://www.example.com/the_hidden_page?setting=set1&setting2=set2"></iframe>
</code></pre>
<p>The page will need to be 'hidden' so it does not appear in the menu on my site and it... | [
{
"answer_id": 102481,
"author": "suvajit",
"author_id": 28353,
"author_profile": "https://wordpress.stackexchange.com/users/28353",
"pm_score": 1,
"selected": false,
"text": "<p>You can add or remove pages from the menu as per your requirement. If you haven't created a menu yet, create ... | 2013/06/10 | [
"https://wordpress.stackexchange.com/questions/102480",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33920/"
] | I want to create a page that can be embedded in other sites with an embed script like this:
```
<iframe src="http://www.example.com/the_hidden_page?setting=set1&setting2=set2"></iframe>
```
The page will need to be 'hidden' so it does not appear in the menu on my site and it will need to accept a query string.
The ... | Prerequisite: Custom Plugin
---------------------------
First you'll need a small plugin. Just copypaste it into a `.php` file, add it to some folder, zip and upload it to your installation an you're done.
What it does
------------
This small plugin only checks if the `wpembed` query part is present and if it is set... |
102,518 | <p>I am trying to display data from a custom post type, based on the date that the event will occur. The date is set in a meta box in the cpt.</p>
<p>My code so far is:</p>
<pre><code>$today = date('d/m/Y');
$p_date = get_post_meta($post->ID, '_cmb_training_date', true);
$p_date2 = get_post_meta($post->ID, '_cm... | [
{
"answer_id": 102481,
"author": "suvajit",
"author_id": 28353,
"author_profile": "https://wordpress.stackexchange.com/users/28353",
"pm_score": 1,
"selected": false,
"text": "<p>You can add or remove pages from the menu as per your requirement. If you haven't created a menu yet, create ... | 2013/06/10 | [
"https://wordpress.stackexchange.com/questions/102518",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33936/"
] | I am trying to display data from a custom post type, based on the date that the event will occur. The date is set in a meta box in the cpt.
My code so far is:
```
$today = date('d/m/Y');
$p_date = get_post_meta($post->ID, '_cmb_training_date', true);
$p_date2 = get_post_meta($post->ID, '_cmb_training_start_date', tru... | Prerequisite: Custom Plugin
---------------------------
First you'll need a small plugin. Just copypaste it into a `.php` file, add it to some folder, zip and upload it to your installation an you're done.
What it does
------------
This small plugin only checks if the `wpembed` query part is present and if it is set... |
102,523 | <p>I'm using IIS without any URL re-writing that include an index.php at the end. The custom permalink structure is: <code>/index.php/%year%/%monthnum%/%postname%/</code></p>
<p>The problem is that the home_url function doesn't include the index.php, so if I want to refer to a custom page <code><?php echo home_url(... | [
{
"answer_id": 102524,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 1,
"selected": false,
"text": "<p>You can filter <code>home_url</code>:</p>\n\n<pre><code>add_filter( 'home_url', 'wpse102523_home_url' );\nfunct... | 2013/06/10 | [
"https://wordpress.stackexchange.com/questions/102523",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5433/"
] | I'm using IIS without any URL re-writing that include an index.php at the end. The custom permalink structure is: `/index.php/%year%/%monthnum%/%postname%/`
The problem is that the home\_url function doesn't include the index.php, so if I want to refer to a custom page `<?php echo home_url() . '/my-page/'; ?>` returns... | You can filter `home_url`:
```
add_filter( 'home_url', 'wpse102523_home_url' );
function wpse102523_home_url( $url ) {
return $url . 'index.php/';
}
```
Reference: [Adam Brown's Filter Database](http://adambrown.info/p/wp_hooks/hook/home_url) |
102,526 | <p>I would like to add a custom field for user to select a existing post or page to a post. (eg as related post, or as similar post...) a way that the user can browse trough exisisting and published posts and then select 1, via post editing screen, just like the "LINK FROM EXISTING CONTENT" tool at the TinyMCE</p>
| [
{
"answer_id": 102524,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 1,
"selected": false,
"text": "<p>You can filter <code>home_url</code>:</p>\n\n<pre><code>add_filter( 'home_url', 'wpse102523_home_url' );\nfunct... | 2013/06/10 | [
"https://wordpress.stackexchange.com/questions/102526",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23576/"
] | I would like to add a custom field for user to select a existing post or page to a post. (eg as related post, or as similar post...) a way that the user can browse trough exisisting and published posts and then select 1, via post editing screen, just like the "LINK FROM EXISTING CONTENT" tool at the TinyMCE | You can filter `home_url`:
```
add_filter( 'home_url', 'wpse102523_home_url' );
function wpse102523_home_url( $url ) {
return $url . 'index.php/';
}
```
Reference: [Adam Brown's Filter Database](http://adambrown.info/p/wp_hooks/hook/home_url) |
102,532 | <p>I've used the second-last example showed here:
<a href="https://github.com/scribu/wp-posts-to-posts/wiki/each_connected" rel="nofollow">https://github.com/scribu/wp-posts-to-posts/wiki/each_connected</a></p>
<p>The only difference is that I've put <strong>the_title</strong> after echoing the connected posts. So my ... | [
{
"answer_id": 102534,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": true,
"text": "<p><a href=\"http://queryposts.com/function/wp_reset_postdata/\" rel=\"nofollow\"><code>wp_reset_postdata()</code></a> ... | 2013/06/10 | [
"https://wordpress.stackexchange.com/questions/102532",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32321/"
] | I've used the second-last example showed here:
<https://github.com/scribu/wp-posts-to-posts/wiki/each_connected>
The only difference is that I've put **the\_title** after echoing the connected posts. So my code is:
```
<?php
$my_query = new WP_Query( array(
'post_type' => 'movie'
) );
p2p_type( 'movies_to_actors... | [`wp_reset_postdata()`](http://queryposts.com/function/wp_reset_postdata/) restores the post from *main query*, which you do not seem to be using here at all. So before final `the_title()` call you jump out all the way to that post.
Your code seems to be tad problematic to me because both your outer and inner loops co... |
102,535 | <p>I've been looking for the best WordPress hosting for me and I'm wondering how many MySQL connections at once WordPress requires? I know this is kind of general question but how does it look for you?</p>
<p>I'm going to host around 3-5 WordPress installs and each will have around 80 000 page views monthly (around 20... | [
{
"answer_id": 102534,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": true,
"text": "<p><a href=\"http://queryposts.com/function/wp_reset_postdata/\" rel=\"nofollow\"><code>wp_reset_postdata()</code></a> ... | 2013/06/10 | [
"https://wordpress.stackexchange.com/questions/102535",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | I've been looking for the best WordPress hosting for me and I'm wondering how many MySQL connections at once WordPress requires? I know this is kind of general question but how does it look for you?
I'm going to host around 3-5 WordPress installs and each will have around 80 000 page views monthly (around 20 000 uniqu... | [`wp_reset_postdata()`](http://queryposts.com/function/wp_reset_postdata/) restores the post from *main query*, which you do not seem to be using here at all. So before final `the_title()` call you jump out all the way to that post.
Your code seems to be tad problematic to me because both your outer and inner loops co... |
102,537 | <p>I have a lot of duplicate posts. So, how to delete them (only keep 1 post). If they have same title, they are duplicate posts. Thank you very much ! Have a nice day !</p>
| [
{
"answer_id": 102544,
"author": "Bendoh",
"author_id": 8907,
"author_profile": "https://wordpress.stackexchange.com/users/8907",
"pm_score": 3,
"selected": true,
"text": "<p>I'm not entirely sure you can do this with a single query in MySQL as you can't delete from tables which you refe... | 2013/06/10 | [
"https://wordpress.stackexchange.com/questions/102537",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33555/"
] | I have a lot of duplicate posts. So, how to delete them (only keep 1 post). If they have same title, they are duplicate posts. Thank you very much ! Have a nice day ! | I'm not entirely sure you can do this with a single query in MySQL as you can't delete from tables which you reference in a sub-query. I would actually recommend doing this using [wp-cli](http://wp-cli.org/) and using the WordPress API to delete the duplicate posts (which will also delete any post meta and associated t... |
102,543 | <p>I'm using the following code in my functions.php to show thumbnails in my excerpt:</p>
<pre><code>function pietergoosen_kry_eerste_prentjie() {
global $post;
$first_img = '';
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
retu... | [
{
"answer_id": 102544,
"author": "Bendoh",
"author_id": 8907,
"author_profile": "https://wordpress.stackexchange.com/users/8907",
"pm_score": 3,
"selected": true,
"text": "<p>I'm not entirely sure you can do this with a single query in MySQL as you can't delete from tables which you refe... | 2013/06/10 | [
"https://wordpress.stackexchange.com/questions/102543",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31545/"
] | I'm using the following code in my functions.php to show thumbnails in my excerpt:
```
function pietergoosen_kry_eerste_prentjie() {
global $post;
$first_img = '';
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
return $first_img;
}
funct... | I'm not entirely sure you can do this with a single query in MySQL as you can't delete from tables which you reference in a sub-query. I would actually recommend doing this using [wp-cli](http://wp-cli.org/) and using the WordPress API to delete the duplicate posts (which will also delete any post meta and associated t... |
102,545 | <p>I would like to create a custom WP admin area, that uses custom URLs to navigate thought it and have a custom generated HTML.</p>
<p>A member will be able to login via a custom URL, for example: mysite.com/dashaboard or my.mysite.com When logged in a member will be able to see custom admin area where she/he can cre... | [
{
"answer_id": 102544,
"author": "Bendoh",
"author_id": 8907,
"author_profile": "https://wordpress.stackexchange.com/users/8907",
"pm_score": 3,
"selected": true,
"text": "<p>I'm not entirely sure you can do this with a single query in MySQL as you can't delete from tables which you refe... | 2013/06/10 | [
"https://wordpress.stackexchange.com/questions/102545",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1343/"
] | I would like to create a custom WP admin area, that uses custom URLs to navigate thought it and have a custom generated HTML.
A member will be able to login via a custom URL, for example: mysite.com/dashaboard or my.mysite.com When logged in a member will be able to see custom admin area where she/he can create pages,... | I'm not entirely sure you can do this with a single query in MySQL as you can't delete from tables which you reference in a sub-query. I would actually recommend doing this using [wp-cli](http://wp-cli.org/) and using the WordPress API to delete the duplicate posts (which will also delete any post meta and associated t... |
102,551 | <p>I would like to add itemprop="articleSection" to a thumbnail.</p>
<pre><code><?php the_post_thumbnail('thmb-index'); ?>
</code></pre>
<p>This is what I've tried:</p>
<pre><code><?php the_post_thumbnail('post-thumbnail',array('itemprop'=>'image')); ?>
</code></pre>
<p>How can I do this in the most ... | [
{
"answer_id": 102556,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<p>What you are trying to do works for me. That is, this works when I try it:</p>\n\n<pre><code>the_post_thumbna... | 2013/06/10 | [
"https://wordpress.stackexchange.com/questions/102551",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | I would like to add itemprop="articleSection" to a thumbnail.
```
<?php the_post_thumbnail('thmb-index'); ?>
```
This is what I've tried:
```
<?php the_post_thumbnail('post-thumbnail',array('itemprop'=>'image')); ?>
```
How can I do this in the most simple and effective way? Preferably, I would like to incorporat... | What you are trying to do works for me. That is, this works when I try it:
```
the_post_thumbnail('post-thumbnail',array('itemprop'=> 'articleSection'));
```
I get the `itemprop` attribute is my `<img` tag. If that isn't working for you I can only guess at why. Possibly there is a filter causing problems.
For a mo... |
102,554 | <p>WordPress automatically checks for updates to itself and all installed themes and plugins. This adds an annoyingly long delay to loading (<em>any</em>) WordPress pages. In only happens once per day and subsequent page-loads don’t do it, but it is so long, that it makes me think twice about whether it is worth openin... | [
{
"answer_id": 102575,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>Mark Jarquith already posted about this on his blog a while ago. Basically it just bails requests to the public SV... | 2013/06/10 | [
"https://wordpress.stackexchange.com/questions/102554",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121/"
] | WordPress automatically checks for updates to itself and all installed themes and plugins. This adds an annoyingly long delay to loading (*any*) WordPress pages. In only happens once per day and subsequent page-loads don’t do it, but it is so long, that it makes me think twice about whether it is worth opening that fir... | >
> How to disable core auto updates but enable plugins and themes auto
> updates
>
>
> If you want to stop the autoupdates of the WordPress core, but to
> enable them for your Plugins and/or Themes, you can add these lines in
> the wp-config.php file: Stop the core auto updates:
>
>
>
```
define( 'WP_AUTO_UP... |
102,555 | <p>In my plugin, I use the following code to retrieve an option from the database:</p>
<pre><code>$options = get_option('my_plugin_options');
</code></pre>
<p>If I use this 10 times in various functions of my plugin, does WordPress make 10 queries to the database, or does it only make 1 database call per HTTP request... | [
{
"answer_id": 102557,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 6,
"selected": true,
"text": "<p>When in doubt, look at the source code.</p>\n\n<p>Digging in to <code>get_option()</code>, you'll see (abbreviated):<... | 2013/06/10 | [
"https://wordpress.stackexchange.com/questions/102555",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32110/"
] | In my plugin, I use the following code to retrieve an option from the database:
```
$options = get_option('my_plugin_options');
```
If I use this 10 times in various functions of my plugin, does WordPress make 10 queries to the database, or does it only make 1 database call per HTTP request and cache the results? | When in doubt, look at the source code.
Digging in to `get_option()`, you'll see (abbreviated):
```
$value = wp_cache_get( $option, 'options' );
if ( false === $value ) {
$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
// Has to ... |
102,559 | <p>At Google's 2013 IO conference, one of their many announcements was the ability to host PHP sites and apps on their Google Apps Engine. They even created a tutorial explaining how to set up a Wordpress site on GAE: <a href="https://developers.google.com/appengine/articles/wordpress" rel="nofollow">https://developers... | [
{
"answer_id": 102557,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 6,
"selected": true,
"text": "<p>When in doubt, look at the source code.</p>\n\n<p>Digging in to <code>get_option()</code>, you'll see (abbreviated):<... | 2013/06/10 | [
"https://wordpress.stackexchange.com/questions/102559",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14822/"
] | At Google's 2013 IO conference, one of their many announcements was the ability to host PHP sites and apps on their Google Apps Engine. They even created a tutorial explaining how to set up a Wordpress site on GAE: <https://developers.google.com/appengine/articles/wordpress>.
I am curious about the supposed performan... | When in doubt, look at the source code.
Digging in to `get_option()`, you'll see (abbreviated):
```
$value = wp_cache_get( $option, 'options' );
if ( false === $value ) {
$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
// Has to ... |
102,585 | <p>I hope this question doesn't make me look too stupid!</p>
<p>I am using a plugin called 'Query Multiple Taxonomies' -- it's a fantastic plugin and is written extraordinarily well. <a href="http://wordpress.org/plugins/query-multiple-taxonomies/" rel="nofollow">http://wordpress.org/plugins/query-multiple-taxonomies/... | [
{
"answer_id": 102830,
"author": "Ravinder Kumar",
"author_id": 29439,
"author_profile": "https://wordpress.stackexchange.com/users/29439",
"pm_score": 0,
"selected": false,
"text": "<p>I think this can be achieve with wordpress <a href=\"http://codex.wordpress.org/Template_Hierarchy#Cus... | 2013/06/11 | [
"https://wordpress.stackexchange.com/questions/102585",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2479/"
] | I hope this question doesn't make me look too stupid!
I am using a plugin called 'Query Multiple Taxonomies' -- it's a fantastic plugin and is written extraordinarily well. <http://wordpress.org/plugins/query-multiple-taxonomies/>
It does *just* about everything that I need it to do save one small thing. I've been tr... | I had done some work for my upcoming theme which shows category tree (Taxonomy drill down) from custom taxonomy. You can show it on taxonomy page or on category page.
```
if(! defined('TH_TAX_TYPE')) define('TH_TAX_TYPE','your-tax-type');
function is_decendent($term_id,$main_parent) {
$terms= get_term_by('id', $te... |
102,621 | <p>I'm not a coder so I may have done some "coding" crimes, apologies. I've bought a theme who has shortcodes for last posts but not for last "custom post type". So I tried to create last "custom post type" function modifying the Last post function provided.
Last post funtion:</p>
<pre><code>function get_custom_posts(... | [
{
"answer_id": 102623,
"author": "Pradipta Sarkar",
"author_id": 33850,
"author_profile": "https://wordpress.stackexchange.com/users/33850",
"pm_score": -1,
"selected": false,
"text": "<p>I'm review your code throughly but the problem is in the wp_query parameter.so please replace this l... | 2013/06/11 | [
"https://wordpress.stackexchange.com/questions/102621",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33980/"
] | I'm not a coder so I may have done some "coding" crimes, apologies. I've bought a theme who has shortcodes for last posts but not for last "custom post type". So I tried to create last "custom post type" function modifying the Last post function provided.
Last post funtion:
```
function get_custom_posts( $params ) {
e... | This seems to work with custom post type :
```
function get_custom_posts( $params ) {
extract( shortcode_atts( array (
'number' => '1',
'excerpt' => 290,
'readmore' => 'no',
'cpt' => 'post',
'readmoretext' => 'Read more'
), $params ) );
//$latest_posts = get_posts( 'category=0&numberposts=' . $number . '&suppre... |
102,655 | <p>I have two hierarchical custom taxonomies, each on a corresponding custom post type. I would like to remove the metabox for each on the post type's edit screen.</p>
<p>I have read <a href="https://wordpress.stackexchange.com/questions/74739/remove-custom-taxonomy-metabox-form-custom-post-type">remove custom taxonom... | [
{
"answer_id": 102656,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": false,
"text": "<p>You say you want to remove the boxes from the <code>post</code> edit screen, not the Post type screen, so as... | 2013/06/11 | [
"https://wordpress.stackexchange.com/questions/102655",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9844/"
] | I have two hierarchical custom taxonomies, each on a corresponding custom post type. I would like to remove the metabox for each on the post type's edit screen.
I have read [remove custom taxonomy metabox form custom post type](https://wordpress.stackexchange.com/questions/74739/remove-custom-taxonomy-metabox-form-cus... | If you are manually registering your custom taxonomy via [register\_taxonomy](https://codex.wordpress.org/Function_Reference/register_taxonomy) then you can pass in arguments to control where the metabox appears.
In the example below setting `show_ui` to `false` would completely remove the metabox from the edit scree... |
102,668 | <p>How would I display a list of my child pages using featured images on a its parent page as well as its other siblings child page?</p>
<p>For example, if my parent page is called 'Music', I'll have my main content with child pages thumbnails at the bottom.</p>
<p>I'd like to have thumbnails with permalinks to other... | [
{
"answer_id": 102678,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/get_ancestors\" rel=\"nofollow\"><code>get_ances... | 2013/06/11 | [
"https://wordpress.stackexchange.com/questions/102668",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33995/"
] | How would I display a list of my child pages using featured images on a its parent page as well as its other siblings child page?
For example, if my parent page is called 'Music', I'll have my main content with child pages thumbnails at the bottom.
I'd like to have thumbnails with permalinks to other child pages from... | Use [`get_ancestors`](http://codex.wordpress.org/Function_Reference/get_ancestors) to get the page parent, then get the children of that parent.
```
$ancestors = array();
$ancestors = get_ancestors($post->ID,'page');
$parent = (!empty($ancestors)) ? array_pop($ancestors) : $post->ID;
if (!empty($parent)) {
$kids = n... |
102,677 | <p>I have a problem (of course) and I'll go straight to the point:
I need to list all the custom categories and count the posts for each category
eg.</p>
<ul>
<li>Category 1 (xx posts)</li>
<li>Category 2 (yy posts) </li>
<li>etc..</li>
</ul>
<p>I tried a couple of queries but with no luck.
All these categories are s... | [
{
"answer_id": 102693,
"author": "whiteletters in blankpapers",
"author_id": 16048,
"author_profile": "https://wordpress.stackexchange.com/users/16048",
"pm_score": 0,
"selected": false,
"text": "<p>Something like this should work (I have tested it in a custom template file).</p>\n\n<pre... | 2013/06/11 | [
"https://wordpress.stackexchange.com/questions/102677",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33997/"
] | I have a problem (of course) and I'll go straight to the point:
I need to list all the custom categories and count the posts for each category
eg.
* Category 1 (xx posts)
* Category 2 (yy posts)
* etc..
I tried a couple of queries but with no luck.
All these categories are stored in the wp\_terms table, how do I list... | After struggling a little bit, I found a solution writing this:
```
<?php
$cat_args = array('orderby' => 'name', 'show_count' => '1', 'hierarchical' => '0','taxonomy' => 'here goes the taxonomy');?>
<ul>
<?php
$cat_args['title_li'] = '';
wp_list_categories(apply_filters('', $cat_args));
?>
</u... |
102,681 | <p>For one of my many sites, <code>plugins/plugin-name</code> is a sym link pointing to <code>universal-install/wp-content/plugins/plugin-name</code>.</p>
<p><code>echo WP_PLUGIN_URL</code> displays what I expect.<br>
<code>echo plugins_url();</code> displays what I expect.<br>
<code>echo plugins_url('',__FILE__)</cod... | [
{
"answer_id": 102693,
"author": "whiteletters in blankpapers",
"author_id": 16048,
"author_profile": "https://wordpress.stackexchange.com/users/16048",
"pm_score": 0,
"selected": false,
"text": "<p>Something like this should work (I have tested it in a custom template file).</p>\n\n<pre... | 2013/06/11 | [
"https://wordpress.stackexchange.com/questions/102681",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33998/"
] | For one of my many sites, `plugins/plugin-name` is a sym link pointing to `universal-install/wp-content/plugins/plugin-name`.
`echo WP_PLUGIN_URL` displays what I expect.
`echo plugins_url();` displays what I expect.
`echo plugins_url('',__FILE__)` displays what I expect followed immediately by the absolute path... | After struggling a little bit, I found a solution writing this:
```
<?php
$cat_args = array('orderby' => 'name', 'show_count' => '1', 'hierarchical' => '0','taxonomy' => 'here goes the taxonomy');?>
<ul>
<?php
$cat_args['title_li'] = '';
wp_list_categories(apply_filters('', $cat_args));
?>
</u... |
102,686 | <p>I'm really scratching my head trying to figure out the best method for responsive images with Wordpress. Zurb just released a new javascript plugin for their Foundation framework. I'm using Foundation in my custom theme, but I'm just unsure as to how to make featured images work with this? Can anyone help me out wit... | [
{
"answer_id": 102819,
"author": "Myk Klemme",
"author_id": 34062,
"author_profile": "https://wordpress.stackexchange.com/users/34062",
"pm_score": 3,
"selected": true,
"text": "<p>If you haven't already enabled thumbnails in your theme, add this snippit to your functions.php:</p>\n\n<pr... | 2013/06/12 | [
"https://wordpress.stackexchange.com/questions/102686",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17837/"
] | I'm really scratching my head trying to figure out the best method for responsive images with Wordpress. Zurb just released a new javascript plugin for their Foundation framework. I'm using Foundation in my custom theme, but I'm just unsure as to how to make featured images work with this? Can anyone help me out with g... | If you haven't already enabled thumbnails in your theme, add this snippit to your functions.php:
```
add_theme_support('post-thumbnails');
```
Then add this code.
```
add_image_size( 'responsive-small', 300, 500 );
add_image_size( 'responsive-large', 768, 500 );
```
Here's how it works:
```
function( 'unique_i... |
102,704 | <p>I don't know why WP themes do not support taxonomy homepages. I mean there should be a separate template for <code>example.com/location/</code> (this may show a list of available taxonomy terms etc.) in addition to <code>example.com/location/newyork/</code> where location is a taxonomy.</p>
<p>What is the best way ... | [
{
"answer_id": 102707,
"author": "Christopher",
"author_id": 1340,
"author_profile": "https://wordpress.stackexchange.com/users/1340",
"pm_score": 0,
"selected": false,
"text": "<p>Taxonomies actually do have archive pages like that, in the same way that categories do. You just have to b... | 2013/06/12 | [
"https://wordpress.stackexchange.com/questions/102704",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6076/"
] | I don't know why WP themes do not support taxonomy homepages. I mean there should be a separate template for `example.com/location/` (this may show a list of available taxonomy terms etc.) in addition to `example.com/location/newyork/` where location is a taxonomy.
What is the best way to have a taxonomy home? A page ... | The /location page doesn't exist because WordPress doesn't just make a page based off your URL structure.
You can create a "Page" called "location" if you need to show content there.
and if you want to list the available terms you have in the location taxonomy you can create a [**custom page template**](http://codex.... |
102,734 | <p>Is it possible to make wpdb->get_row return an object of a my own custom class instead of stdClass?</p>
| [
{
"answer_id": 102738,
"author": "ndm",
"author_id": 20949,
"author_profile": "https://wordpress.stackexchange.com/users/20949",
"pm_score": 1,
"selected": false,
"text": "<p>Doesn't look like it's possible, at least there doesn't seem to be an elegant way. <a href=\"http://core.trac.wor... | 2013/06/12 | [
"https://wordpress.stackexchange.com/questions/102734",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34026/"
] | Is it possible to make wpdb->get\_row return an object of a my own custom class instead of stdClass? | Doesn't look like it's possible, at least there doesn't seem to be an elegant way. [`get_row()`](http://core.trac.wordpress.org/browser/trunk/wp-includes/wp-db.php#L1452) invokes [`query()`](http://core.trac.wordpress.org/browser/trunk/wp-includes/wp-db.php#L1176), which uses [`mysql_fetch_object()`](http://php.net/man... |
102,737 | <p>I am trying to figure out if I understand the migration process correctly for a very important migration I have planned.</p>
<ol>
<li>I am currently hosting a clients site as an <code>Add On</code> domain on my personal account.
<strong>www.example.com</strong></li>
<li>I have created an account for them on my rese... | [
{
"answer_id": 102738,
"author": "ndm",
"author_id": 20949,
"author_profile": "https://wordpress.stackexchange.com/users/20949",
"pm_score": 1,
"selected": false,
"text": "<p>Doesn't look like it's possible, at least there doesn't seem to be an elegant way. <a href=\"http://core.trac.wor... | 2013/06/12 | [
"https://wordpress.stackexchange.com/questions/102737",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33809/"
] | I am trying to figure out if I understand the migration process correctly for a very important migration I have planned.
1. I am currently hosting a clients site as an `Add On` domain on my personal account.
**www.example.com**
2. I have created an account for them on my reseller WHM system using the same domain name.... | Doesn't look like it's possible, at least there doesn't seem to be an elegant way. [`get_row()`](http://core.trac.wordpress.org/browser/trunk/wp-includes/wp-db.php#L1452) invokes [`query()`](http://core.trac.wordpress.org/browser/trunk/wp-includes/wp-db.php#L1176), which uses [`mysql_fetch_object()`](http://php.net/man... |
102,780 | <p>I was looking to change the "Wordpress" name in all of my sent mail. In the past I have customized my Wordpress backend to display my desired email. But I have downloaded a new plugin that has altered the email name field. I went to attempt to change it again but this time in the pluggable.php template file. </p>
<... | [
{
"answer_id": 102781,
"author": "a web dev",
"author_id": 33840,
"author_profile": "https://wordpress.stackexchange.com/users/33840",
"pm_score": 2,
"selected": false,
"text": "<p>Don't mess around with changing those files directly. It will break when that file gets changed in an updat... | 2013/06/12 | [
"https://wordpress.stackexchange.com/questions/102780",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30789/"
] | I was looking to change the "Wordpress" name in all of my sent mail. In the past I have customized my Wordpress backend to display my desired email. But I have downloaded a new plugin that has altered the email name field. I went to attempt to change it again but this time in the pluggable.php template file.
However ... | Don't mess around with changing those files directly. It will break when that file gets changed in an update. Do this instead.
```
add_filter( 'wp_mail_from', 'override_mail_from_address' );
add_filter( 'wp_mail_from_name', 'override_mail_from_name' );
function override_mail_from_address($email_address) {
$from_a... |
102,804 | <p>Im using wp_dropdown_categories for a page. Issue im having is i dont want it to show the current category that the page is on as the title, i want it always to display the "Select A Category" text i have placed in the options. Current code is:</p>
<pre><code>wp_dropdown_categories( 'show_option_none=Select A Categ... | [
{
"answer_id": 102815,
"author": "Jaime Gris",
"author_id": 4535,
"author_profile": "https://wordpress.stackexchange.com/users/4535",
"pm_score": 0,
"selected": false,
"text": "<p>Try using the <code>exclude</code> parameter.</p>\n\n<pre><code>wp_dropdown_categories('show_option_none=Sel... | 2013/06/13 | [
"https://wordpress.stackexchange.com/questions/102804",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31195/"
] | Im using wp\_dropdown\_categories for a page. Issue im having is i dont want it to show the current category that the page is on as the title, i want it always to display the "Select A Category" text i have placed in the options. Current code is:
```
wp_dropdown_categories( 'show_option_none=Select A Category&show_cou... | You can use [`get_query_var( )`](http://codex.wordpress.org/Function_Reference/get_query_var) to fetch the current category:
```
$cat = get_query_var( 'cat' );
```
You can use this `$cat` in the exclude parameter of `wp_dropdown_categories( )` to hide the current category:
```
$args = array(
'show_option_none' =>... |
102,829 | <p>I'm making a custom function for my WordPress site.</p>
<pre><code>function mediumFeaturedImage() {
if ( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail( 'medium' ); ?>
</a>
<?php } else { ?> ... | [
{
"answer_id": 102831,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 0,
"selected": false,
"text": "<p>PHP has a function called <a href=\"http://php.net/manual/en/function.getimagesize.php\" rel=\"nofollow\"><co... | 2013/06/13 | [
"https://wordpress.stackexchange.com/questions/102829",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22728/"
] | I'm making a custom function for my WordPress site.
```
function mediumFeaturedImage() {
if ( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail( 'medium' ); ?>
</a>
<?php } else { ?>
<img src="<?php echo get_template_di... | I think you want wordpress setting for media
for medium size their are
```
get_option('medium_size_w');//width
get_option('medium_size_h');//height
```
all setting store in options table.[get more media setting](http://codex.wordpress.org/Option_Reference#Media) |
102,833 | <p>We are running a news site based on WP 3.5.1. Some editors complain that the WYSIWYG editor on the post editing page is not working properly for some posts. The editing buttons are not shown.</p>
<p>In some cases we need to update a post many times (like more than 500 times).<br>
May it be the cause?<br>
What will ... | [
{
"answer_id": 102831,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 0,
"selected": false,
"text": "<p>PHP has a function called <a href=\"http://php.net/manual/en/function.getimagesize.php\" rel=\"nofollow\"><co... | 2013/06/13 | [
"https://wordpress.stackexchange.com/questions/102833",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25344/"
] | We are running a news site based on WP 3.5.1. Some editors complain that the WYSIWYG editor on the post editing page is not working properly for some posts. The editing buttons are not shown.
In some cases we need to update a post many times (like more than 500 times).
May it be the cause?
What will happen to th... | I think you want wordpress setting for media
for medium size their are
```
get_option('medium_size_w');//width
get_option('medium_size_h');//height
```
all setting store in options table.[get more media setting](http://codex.wordpress.org/Option_Reference#Media) |
102,841 | <p>I'm pretty new to WordPress and I was wondering if I could get a <code>page id</code> with its <code>slug</code>. Is it possible please let me know?</p>
| [
{
"answer_id": 102844,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 7,
"selected": true,
"text": "<p>Use <code>get_page_by_path($page_path)</code>:</p>\n<pre><code>$page = get_page_by_path( 'about' );\necho get_the_titl... | 2013/06/13 | [
"https://wordpress.stackexchange.com/questions/102841",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33747/"
] | I'm pretty new to WordPress and I was wondering if I could get a `page id` with its `slug`. Is it possible please let me know? | Use `get_page_by_path($page_path)`:
```
$page = get_page_by_path( 'about' );
echo get_the_title( $page );
```
This will return a regular post object.
**Documentation:**
<https://developer.wordpress.org/reference/functions/get_page_by_path/>
<https://developer.wordpress.org/reference/functions/get_the_title... |
102,854 | <p>Moreso a psuedo-code question than actual code. I have some custom post meta attached to attachments, and created a list table column for this meta. The meta is either 1, or null (not set), but I am trying to enable sorting for said column.</p>
<p>Is there a way to utilize <code>meta_query</code> for WP_Query to e... | [
{
"answer_id": 102844,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 7,
"selected": true,
"text": "<p>Use <code>get_page_by_path($page_path)</code>:</p>\n<pre><code>$page = get_page_by_path( 'about' );\necho get_the_titl... | 2013/06/13 | [
"https://wordpress.stackexchange.com/questions/102854",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23454/"
] | Moreso a psuedo-code question than actual code. I have some custom post meta attached to attachments, and created a list table column for this meta. The meta is either 1, or null (not set), but I am trying to enable sorting for said column.
Is there a way to utilize `meta_query` for WP\_Query to essentially LEFT JOIN,... | Use `get_page_by_path($page_path)`:
```
$page = get_page_by_path( 'about' );
echo get_the_title( $page );
```
This will return a regular post object.
**Documentation:**
<https://developer.wordpress.org/reference/functions/get_page_by_path/>
<https://developer.wordpress.org/reference/functions/get_the_title... |
102,861 | <p>I do have a problem with a custom post pagination. I search through this site and googled the whole day yesterday, and found nothing that was similar to what I experience (or I'm getting blind...).</p>
<p>Here is my custom post "recipe":</p>
<pre><code>register_post_type( 'recipe', array(
'labels' => array(
... | [
{
"answer_id": 102867,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>They're not the same. Your news page is the posts page, and your recipes page is a page post type where you've use... | 2013/06/13 | [
"https://wordpress.stackexchange.com/questions/102861",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34071/"
] | I do have a problem with a custom post pagination. I search through this site and googled the whole day yesterday, and found nothing that was similar to what I experience (or I'm getting blind...).
Here is my custom post "recipe":
```
register_post_type( 'recipe', array(
'labels' => array(
'name' =>... | Finally, I was able to solve it.
The problem was caused by a plugin, 404 Redirected.
It catched my URL and decided that it needed to add a 301 redirection on my URL and then send it to the URL without pagination... |
102,880 | <p>I am developing a job tracking database for my utility engineering company and am having an issue when running a save hook. I have a task_types db table that tasks are created off of and using a custom meta box on the "cover_page" (post edit screen) of the job I allow these tasks to be created for each job from use... | [
{
"answer_id": 102867,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>They're not the same. Your news page is the posts page, and your recipes page is a page post type where you've use... | 2013/06/13 | [
"https://wordpress.stackexchange.com/questions/102880",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22983/"
] | I am developing a job tracking database for my utility engineering company and am having an issue when running a save hook. I have a task\_types db table that tasks are created off of and using a custom meta box on the "cover\_page" (post edit screen) of the job I allow these tasks to be created for each job from user ... | Finally, I was able to solve it.
The problem was caused by a plugin, 404 Redirected.
It catched my URL and decided that it needed to add a 301 redirection on my URL and then send it to the URL without pagination... |
102,882 | <p>I have a wordpress page that has a series of listings and a searchbox at the top. The search allows the user to filter posts by creating a custom WP_Query object based on what they selected. I am wondering if there is a way I can have this be paginated so that there aren't hundreds of results displaying on the page.... | [
{
"answer_id": 102891,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>Based on the code you posted, you are not passing any <code>meta</code> parameters through to the pagination... | 2013/06/13 | [
"https://wordpress.stackexchange.com/questions/102882",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24385/"
] | I have a wordpress page that has a series of listings and a searchbox at the top. The search allows the user to filter posts by creating a custom WP\_Query object based on what they selected. I am wondering if there is a way I can have this be paginated so that there aren't hundreds of results displaying on the page.
... | I was going to create my own question and answer it, but this looks as good a place as any. The way I solved this, is by using $\_SESSION. Keep in mind I am using infinite-scroll, so I can tell when the page is being fetched via ajax as opposed to being actually navigated to in the browser.
So here's the steps/pseudo... |
102,894 | <p>I am using <code>list_author_used_terms</code> function below to get the terms used by a specific author (terms of a custom taxonomy 'wossom' for a custom post type 'aya-bi-aya').</p>
<pre><code>function list_author_used_terms($author_id){
$posts = get_posts( array('post_type' => 'aya-bi-aya', 'posts_per_pa... | [
{
"answer_id": 102898,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>I don't know which line that error refers to but this code works correctly if everything falls into place ex... | 2013/06/13 | [
"https://wordpress.stackexchange.com/questions/102894",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16048/"
] | I am using `list_author_used_terms` function below to get the terms used by a specific author (terms of a custom taxonomy 'wossom' for a custom post type 'aya-bi-aya').
```
function list_author_used_terms($author_id){
$posts = get_posts( array('post_type' => 'aya-bi-aya', 'posts_per_page' => -1, 'author' => $auth... | I learned from Rarst and S\_ha\_dum two new nice techniques that I want to share with everybody beginner in coding PHP/Wordpress:
* `Var_dump` function is useful to check what is the nature of a
variable during the steps of code.
* geting into the habit of verifying that you have the kind of data you
think you have be... |
102,920 | <p>There is no links manager in the admin_menu of Wordpress 3.5.1 anymore. I'm creating a custom add_links_page, and I'm having a hard time with the making a plugin.</p>
<p>Do I need to initialize something to show the links page?</p>
| [
{
"answer_id": 102940,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 4,
"selected": true,
"text": "<p>It's commonly activated through:</p>\n\n<pre><code>add_filter( 'pre_option_link_manager_enabled', '__return_tr... | 2013/06/14 | [
"https://wordpress.stackexchange.com/questions/102920",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33828/"
] | There is no links manager in the admin\_menu of Wordpress 3.5.1 anymore. I'm creating a custom add\_links\_page, and I'm having a hard time with the making a plugin.
Do I need to initialize something to show the links page? | It's commonly activated through:
```
add_filter( 'pre_option_link_manager_enabled', '__return_true' );
```
The suggested `Link Manager` plugin only contains this code line. |
102,950 | <p>I'm using WPML plugin to translate my site.
I have a custom post type called "vinos" and I use this args:</p>
<pre><code>$args = array(
'labels' => $labels,
'hierarchical' => false,
'supports' => array('title', 'thumbnail'),
'public' => true,
... | [
{
"answer_id": 102987,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Try the solution mentioned here:\n<a href=\"http://wpengineer.com/2044/custom-post-type-and-permalink/\" rel=\"no... | 2013/06/14 | [
"https://wordpress.stackexchange.com/questions/102950",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27877/"
] | I'm using WPML plugin to translate my site.
I have a custom post type called "vinos" and I use this args:
```
$args = array(
'labels' => $labels,
'hierarchical' => false,
'supports' => array('title', 'thumbnail'),
'public' => true,
'show_ui' => true,
... | this will not work:
```
'en/index.php?post_type=vinos'
```
there is no `en/index.php`, it has to be:
```
'index.php?post_type=vinos'
```
if you need to detect `en` in the path, add a query var, then set that query var in your rewrite:
```
function wpa_query_vars( $qvars ) {
$qvars[] = 'wpa_lang';
return ... |
102,977 | <p>all,</p>
<p>I've been struggling with this for the past two days, I just can't find the answer - sorry if I post this in the wrong site but this is the best option I could think of.</p>
<p>I have some problems with a site that I troubleshot all the way until they led me to this particular problem. If I want to dow... | [
{
"answer_id": 102987,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Try the solution mentioned here:\n<a href=\"http://wpengineer.com/2044/custom-post-type-and-permalink/\" rel=\"no... | 2013/06/14 | [
"https://wordpress.stackexchange.com/questions/102977",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22877/"
] | all,
I've been struggling with this for the past two days, I just can't find the answer - sorry if I post this in the wrong site but this is the best option I could think of.
I have some problems with a site that I troubleshot all the way until they led me to this particular problem. If I want to download a PHP file ... | this will not work:
```
'en/index.php?post_type=vinos'
```
there is no `en/index.php`, it has to be:
```
'index.php?post_type=vinos'
```
if you need to detect `en` in the path, add a query var, then set that query var in your rewrite:
```
function wpa_query_vars( $qvars ) {
$qvars[] = 'wpa_lang';
return ... |
102,989 | <p>In my loop I've added:</p>
<pre><code><?php
$categories = get_the_category();
$separator = ' ';
$output = '';
if($categories){
foreach($categories as $category) {
$output .= '<span class="post-category-info"><a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprint... | [
{
"answer_id": 102992,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p><code>$category</code> is an object containing member variables, you have to check the specific member var you want... | 2013/06/14 | [
"https://wordpress.stackexchange.com/questions/102989",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14948/"
] | In my loop I've added:
```
<?php
$categories = get_the_category();
$separator = ' ';
$output = '';
if($categories){
foreach($categories as $category) {
$output .= '<span class="post-category-info"><a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s"... | `$category` is an object containing member variables, you have to check the specific member var you want to compare.
change:
```
if($category !== 'Featured')
```
to:
```
if($category->name !== 'Featured')
``` |
102,996 | <p>I hope to make my life easy by doing this. I have 2 types of posts. On the first post I have a table and each post from the respective category will fill a table row.
I will show you how a posts of mine looks like the following:</p>
<pre><code><tr><td class="expand footable-first-column">SA Spurs</t... | [
{
"answer_id": 102992,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p><code>$category</code> is an object containing member variables, you have to check the specific member var you want... | 2013/06/14 | [
"https://wordpress.stackexchange.com/questions/102996",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33622/"
] | I hope to make my life easy by doing this. I have 2 types of posts. On the first post I have a table and each post from the respective category will fill a table row.
I will show you how a posts of mine looks like the following:
```
<tr><td class="expand footable-first-column">SA Spurs</td>
<td class="away">Miami Hea... | `$category` is an object containing member variables, you have to check the specific member var you want to compare.
change:
```
if($category !== 'Featured')
```
to:
```
if($category->name !== 'Featured')
``` |
103,006 | <p>I'm having trouble fixing this for working in ie8, i find out thats last comma is problem, but dont know how to fix it.</p>
<p>this is current code.</p>
<pre><code><?php $args = array( 'post_type' => 'katalog', 'posts_per_page' => 999 );
$loop = new WP_Query( $args );
if ($loop->have_posts()) :
while... | [
{
"answer_id": 103008,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": -1,
"selected": false,
"text": "<p>While this can be done in PHP, I prefer using some markup and css peudo-class such as <a href=\"http://www.w3sc... | 2013/06/14 | [
"https://wordpress.stackexchange.com/questions/103006",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1853/"
] | I'm having trouble fixing this for working in ie8, i find out thats last comma is problem, but dont know how to fix it.
this is current code.
```
<?php $args = array( 'post_type' => 'katalog', 'posts_per_page' => 999 );
$loop = new WP_Query( $args );
if ($loop->have_posts()) :
while ($loop->have_posts()) : $loop->t... | Looks like you're trying to build up some JSON. Why not use what PHP already provides, which has the advantage of escaping characters too?
```
global $post;
$data = array();
if ($loop->have_posts()) {
while ($loop->have_posts()) {
$loop->the_post();
$thumb=wp_get_attachment_image_src( get_post_th... |
103,050 | <p>We have converted a static site to a Wordpress site with a theme which we designed and built. However, not having a massive amount of Wordpress experience we don't know how to approach this problem.</p>
<p>Our site has several pages, all of course using the page.php template. That's working fine for the content. Bu... | [
{
"answer_id": 103074,
"author": "Gniewomir Świechowski",
"author_id": 24610,
"author_profile": "https://wordpress.stackexchange.com/users/24610",
"pm_score": 0,
"selected": false,
"text": "<p>In comments you have few good ideas for complex solution, but if your client is moving a static... | 2013/06/15 | [
"https://wordpress.stackexchange.com/questions/103050",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/875/"
] | We have converted a static site to a Wordpress site with a theme which we designed and built. However, not having a massive amount of Wordpress experience we don't know how to approach this problem.
Our site has several pages, all of course using the page.php template. That's working fine for the content. But every pa... | Generally since WordPress' biggest selling point is it's content management, what clients want the most are sites they can edit without any code in the way or any chances that they might break something - so putting html in the text editor beyond unordered/ordered lists is bad practice and defeats the point of making c... |
103,051 | <p>Is it posible only with 1 loop, to show all posts, but show first the posts in one specific tag?</p>
<p>The solutions i found, are using more than 1 loop. </p>
<p>If this is not possible, maybe if the post has a meta custom field called priority =1 , there is a solution to show this posts first.</p>
<p>Thank you ... | [
{
"answer_id": 103053,
"author": "Rohit Pande",
"author_id": 21274,
"author_profile": "https://wordpress.stackexchange.com/users/21274",
"pm_score": 1,
"selected": false,
"text": "<p>You can use <code>meta key</code> for ordering your result.</p>\n\n<p>See reference from codex <a href=\"... | 2013/06/15 | [
"https://wordpress.stackexchange.com/questions/103051",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28474/"
] | Is it posible only with 1 loop, to show all posts, but show first the posts in one specific tag?
The solutions i found, are using more than 1 loop.
If this is not possible, maybe if the post has a meta custom field called priority =1 , there is a solution to show this posts first.
Thank you for your help. | You can use `meta key` for ordering your result.
See reference from codex [here](http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters).
Ex.
```
$args = array(
'post_type' => 'post',
'meta_key' => 'priority',
'orderby' => 'meta_value_num',
'order' => 'ASC'
);
$query = new WP_... |
103,059 | <p>Here is my loop code located in <code>index.php</code> file. I am using Twenty Eleven theme.</p>
<pre><code><?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php end... | [
{
"answer_id": 103053,
"author": "Rohit Pande",
"author_id": 21274,
"author_profile": "https://wordpress.stackexchange.com/users/21274",
"pm_score": 1,
"selected": false,
"text": "<p>You can use <code>meta key</code> for ordering your result.</p>\n\n<p>See reference from codex <a href=\"... | 2013/06/15 | [
"https://wordpress.stackexchange.com/questions/103059",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33963/"
] | Here is my loop code located in `index.php` file. I am using Twenty Eleven theme.
```
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php twentytwelve_content_nav( 'nav-belo... | You can use `meta key` for ordering your result.
See reference from codex [here](http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters).
Ex.
```
$args = array(
'post_type' => 'post',
'meta_key' => 'priority',
'orderby' => 'meta_value_num',
'order' => 'ASC'
);
$query = new WP_... |
103,076 | <p>I am using the <code>User Submitted Posts</code> plugin which I love. The only problem with this plugin is that it does not check for <strong>duplicate post titles</strong> and outputs a post with the same title, even if it already exists.</p>
<p><strong>So I want to know: how can I check if someone clicks on the s... | [
{
"answer_id": 103066,
"author": "Hitesh Siddhapura",
"author_id": 29487,
"author_profile": "https://wordpress.stackexchange.com/users/29487",
"pm_score": -1,
"selected": false,
"text": "<p>You can change link by WORDPRESS SEARCH AND REPLACE TOOL wonderful tool, also WordPress recommend ... | 2013/06/15 | [
"https://wordpress.stackexchange.com/questions/103076",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32731/"
] | I am using the `User Submitted Posts` plugin which I love. The only problem with this plugin is that it does not check for **duplicate post titles** and outputs a post with the same title, even if it already exists.
**So I want to know: how can I check if someone clicks on the submit button, if a post with the same ti... | Well, your steps are pretty much all you need to do, the only other thing I'd do is to use the [WP Migrate DB](http://wordpress.org/plugins/wp-migrate-db/ "WP Migrate DB plugin on WordPress.org") plugin(I personally use it and it saves me a lot of time when migrating the Database) - it supports for change of both URL a... |
103,078 | <p>For example, there are the tags {<code>foo</code>, <code>bar</code>, <code>chocolate</code>, <code>mango</code>, <code>hammock</code>, <code>leaf</code>}</p>
<p>I would like to find all posts with <strong>at least 3 of these tags</strong>.</p>
<p>A post with tags {<code>foo</code>, <code>mango</code>, <code>vannil... | [
{
"answer_id": 103092,
"author": "stellarcowboy",
"author_id": 33207,
"author_profile": "https://wordpress.stackexchange.com/users/33207",
"pm_score": 4,
"selected": true,
"text": "<p>The answer below is simplified, and could be extended to check if <em>any</em> posts have 3 matching tag... | 2013/06/15 | [
"https://wordpress.stackexchange.com/questions/103078",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34076/"
] | For example, there are the tags {`foo`, `bar`, `chocolate`, `mango`, `hammock`, `leaf`}
I would like to find all posts with **at least 3 of these tags**.
A post with tags {`foo`, `mango`, `vannilla`, `nuts`, `leaf`} will match it because it has {`foo`, `mango`, `leaf`} - so at least 3 tags from the needed set of tags... | The answer below is simplified, and could be extended to check if *any* posts have 3 matching tags before outputting the list. Using one query and assuming you have at least one post with 3 matching tags:
```
//List of tag slugs
$tags = array('foo', 'bar', 'chocolate', 'mango', 'hammock', 'leaf');
$args = array(
... |
103,084 | <p>I have been using transients a lot in WordPress since I discovered them, however to ensure my sites update properly when a post is edited or created I added a function to delete transients on post save. </p>
<p>This works great however I need to keep a list of all the transients I create throughout the site and the... | [
{
"answer_id": 103086,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <a href=\"http://codex.wordpress.org/Class_Reference/wpdb\" rel=\"nofollow\">the class <code>wpdb</c... | 2013/06/15 | [
"https://wordpress.stackexchange.com/questions/103084",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112/"
] | I have been using transients a lot in WordPress since I discovered them, however to ensure my sites update properly when a post is edited or created I added a function to delete transients on post save.
This works great however I need to keep a list of all the transients I create throughout the site and then mention ... | The db query would look like this:
```
SELECT `option_name` AS `name`, `option_value` AS `value`
FROM $wpdb->options
WHERE `option_name` LIKE '%transient_%'
ORDER BY `option_name`
```
To sort the results by their function (site transients, timeouts) use a function like this:
```
add_action( 'shutdown', function(){... |
103,108 | <p>this might sound like a very stupid question, and I am almost ashamed to put it here... however, after using the code straight from wp codex, and trying a couple of other variations from googling around, i simply have NO IDEA why this is not working!</p>
<p>here's what i am using for the wp query on the index.php</... | [
{
"answer_id": 103112,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p><a href=\"http://codex.wordpress.org/Taxonomies\" rel=\"nofollow\">Taxonomies</a> and <a href=\"http://codex.wordpr... | 2013/06/16 | [
"https://wordpress.stackexchange.com/questions/103108",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34159/"
] | this might sound like a very stupid question, and I am almost ashamed to put it here... however, after using the code straight from wp codex, and trying a couple of other variations from googling around, i simply have NO IDEA why this is not working!
here's what i am using for the wp query on the index.php
```
$args ... | [Taxonomies](http://codex.wordpress.org/Taxonomies) and [meta data (Custom Fields)](http://codex.wordpress.org/Custom_Fields) are two different things. If you want to filter on a taxonomy term, you want a [`tax_query`](http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters), not a meta query. |
103,119 | <p>I use the following codes to get posts <strong>only</strong> from '<strong>image</strong>' post format and it works.</p>
<pre><code><?php if( has_post_format('image')){ ?>
<?php the_post_thumbnail(); ?>
<?php } ?>
</code></pre>
<p>I also need to get posts <strong>only</strong> from '<strong>st... | [
{
"answer_id": 103120,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 3,
"selected": true,
"text": "<p>Do,</p>\n\n<pre><code><?php if( false == get_post_format() ){ ?>\n <a href=\"<?php the_permalink()... | 2013/06/16 | [
"https://wordpress.stackexchange.com/questions/103119",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34032/"
] | I use the following codes to get posts **only** from '**image**' post format and it works.
```
<?php if( has_post_format('image')){ ?>
<?php the_post_thumbnail(); ?>
<?php } ?>
```
I also need to get posts **only** from '**standard**' post format with the following codes, but it get post from all post formats.
`... | Do,
```
<?php if( false == get_post_format() ){ ?>
<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
<?php } ?>
```
The standard post format isn't actually a post format, so if you conditionally check whether a post contains a post format (other than the default standard), it will retu... |
103,139 | <p>I had an issue today when my sites had stopped working. Calling up the link just showed a cryptic message <code>Database connection error</code>, on all my sites on one server. The error disappeared on rebooting.</p>
<p>While trying to get to the root of the issue, I was examining syslog (I'm using Debian 7), and f... | [
{
"answer_id": 103120,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 3,
"selected": true,
"text": "<p>Do,</p>\n\n<pre><code><?php if( false == get_post_format() ){ ?>\n <a href=\"<?php the_permalink()... | 2013/06/16 | [
"https://wordpress.stackexchange.com/questions/103139",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28555/"
] | I had an issue today when my sites had stopped working. Calling up the link just showed a cryptic message `Database connection error`, on all my sites on one server. The error disappeared on rebooting.
While trying to get to the root of the issue, I was examining syslog (I'm using Debian 7), and found the following en... | Do,
```
<?php if( false == get_post_format() ){ ?>
<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
<?php } ?>
```
The standard post format isn't actually a post format, so if you conditionally check whether a post contains a post format (other than the default standard), it will retu... |
103,142 | <p>I've a custom field in Wordpress user meta, which store data in serialized array. I want to retrieve the number of arrays. For e.g.: <code>a:2:{blah blah}</code></p>
<hr>
<p><img src="https://i.stack.imgur.com/wJvQy.jpg" alt="enter image description here">
<sup>Screenshot of my table</sup></p>
<hr>
<p>I tried th... | [
{
"answer_id": 103120,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 3,
"selected": true,
"text": "<p>Do,</p>\n\n<pre><code><?php if( false == get_post_format() ){ ?>\n <a href=\"<?php the_permalink()... | 2013/06/16 | [
"https://wordpress.stackexchange.com/questions/103142",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23841/"
] | I've a custom field in Wordpress user meta, which store data in serialized array. I want to retrieve the number of arrays. For e.g.: `a:2:{blah blah}`
---

Screenshot of my table
---
I tried the following code but it doesn't works. It should print ... | Do,
```
<?php if( false == get_post_format() ){ ?>
<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
<?php } ?>
```
The standard post format isn't actually a post format, so if you conditionally check whether a post contains a post format (other than the default standard), it will retu... |
103,148 | <p>I am trying to add some ARIA related stuff to the wp_nav_menu function. I use a custom walker class for this purpose:</p>
<pre><code>class Walker_Nav_Menu_With_Aria extends Walker_Nav_Menu {
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);... | [
{
"answer_id": 103153,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 5,
"selected": true,
"text": "<p>I get this error when there are no menus defined or no menus set for the location at <code>Appearance->Men... | 2013/06/16 | [
"https://wordpress.stackexchange.com/questions/103148",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20035/"
] | I am trying to add some ARIA related stuff to the wp\_nav\_menu function. I use a custom walker class for this purpose:
```
class Walker_Nav_Menu_With_Aria extends Walker_Nav_Menu {
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
... | I get this error when there are no menus defined or no menus set for the location at `Appearance->Menus`. When that occurs `wp_nav_menu` uses a page walker fallback.
1. The [fallback (default) for `wp_nav_menu`](http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/nav-menu-template.php#L139) is `wp_walker_pag... |
103,161 | <p>I'm currently using loop_end to hook my plugin and get the post id from a page. This works great, except that it's also displaying my plugin in the recent posts widget which I don't want.</p>
<p>Is there a better way to do this so that it ONLY displays on page content and not widgets?</p>
| [
{
"answer_id": 103153,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 5,
"selected": true,
"text": "<p>I get this error when there are no menus defined or no menus set for the location at <code>Appearance->Men... | 2013/06/16 | [
"https://wordpress.stackexchange.com/questions/103161",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8882/"
] | I'm currently using loop\_end to hook my plugin and get the post id from a page. This works great, except that it's also displaying my plugin in the recent posts widget which I don't want.
Is there a better way to do this so that it ONLY displays on page content and not widgets? | I get this error when there are no menus defined or no menus set for the location at `Appearance->Menus`. When that occurs `wp_nav_menu` uses a page walker fallback.
1. The [fallback (default) for `wp_nav_menu`](http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/nav-menu-template.php#L139) is `wp_walker_pag... |
103,162 | <p>Hi there I'm using the following query to pull in two featured posts onto the home page of a site I'm building. How do I add a last class to the second post it drops onto the page?</p>
<pre><code> <h3>Case Studies</h3>
<?php $my_query = new WP_Query('post_type=casestudy&... | [
{
"answer_id": 103153,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 5,
"selected": true,
"text": "<p>I get this error when there are no menus defined or no menus set for the location at <code>Appearance->Men... | 2013/06/16 | [
"https://wordpress.stackexchange.com/questions/103162",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34181/"
] | Hi there I'm using the following query to pull in two featured posts onto the home page of a site I'm building. How do I add a last class to the second post it drops onto the page?
```
<h3>Case Studies</h3>
<?php $my_query = new WP_Query('post_type=casestudy&posts_per_page=2');
... | I get this error when there are no menus defined or no menus set for the location at `Appearance->Menus`. When that occurs `wp_nav_menu` uses a page walker fallback.
1. The [fallback (default) for `wp_nav_menu`](http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/nav-menu-template.php#L139) is `wp_walker_pag... |
103,181 | <p>i try to run a custom post type query to match following criteria:<br>
sort movies first by year in descending order,<br>
after that ("inside" the year order) by title alphabetically. </p>
<p>desired output:<br>
movie title A, 2006<br>
movie title Z, 2006<br>
...<br>
movie title A, 1996<br>
movie title Z, 1996 ... | [
{
"answer_id": 103153,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 5,
"selected": true,
"text": "<p>I get this error when there are no menus defined or no menus set for the location at <code>Appearance->Men... | 2013/06/16 | [
"https://wordpress.stackexchange.com/questions/103181",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34187/"
] | i try to run a custom post type query to match following criteria:
sort movies first by year in descending order,
after that ("inside" the year order) by title alphabetically.
desired output:
movie title A, 2006
movie title Z, 2006
...
movie title A, 1996
movie title Z, 1996
i use the following... | I get this error when there are no menus defined or no menus set for the location at `Appearance->Menus`. When that occurs `wp_nav_menu` uses a page walker fallback.
1. The [fallback (default) for `wp_nav_menu`](http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/nav-menu-template.php#L139) is `wp_walker_pag... |
103,184 | <p>I am trying to create a table containing information that is a result of two different loops. The first loops through a list of custom post types to display team names. The other is to provide data concerning each of the teams and stored as metadata. So I think I need some way of constructing a double query in order... | [
{
"answer_id": 103153,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 5,
"selected": true,
"text": "<p>I get this error when there are no menus defined or no menus set for the location at <code>Appearance->Men... | 2013/06/16 | [
"https://wordpress.stackexchange.com/questions/103184",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34045/"
] | I am trying to create a table containing information that is a result of two different loops. The first loops through a list of custom post types to display team names. The other is to provide data concerning each of the teams and stored as metadata. So I think I need some way of constructing a double query in order to... | I get this error when there are no menus defined or no menus set for the location at `Appearance->Menus`. When that occurs `wp_nav_menu` uses a page walker fallback.
1. The [fallback (default) for `wp_nav_menu`](http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/nav-menu-template.php#L139) is `wp_walker_pag... |
103,195 | <p>I am creating a e-commerce website. I am using woocommerce with some cool extensions I bought. I need to make 2 websites, but store the users database (purchases, subscription purchases, etc) as well as products in a single database. The rest of the content should be different (pages, posts etc) so the administrator... | [
{
"answer_id": 103206,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 3,
"selected": true,
"text": "<p>You can do the sharing of users fairly easily.</p>\n\n<p>Basically, both sites would use the same databas... | 2013/06/16 | [
"https://wordpress.stackexchange.com/questions/103195",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31047/"
] | I am creating a e-commerce website. I am using woocommerce with some cool extensions I bought. I need to make 2 websites, but store the users database (purchases, subscription purchases, etc) as well as products in a single database. The rest of the content should be different (pages, posts etc) so the administrator ca... | You can do the sharing of users fairly easily.
Basically, both sites would use the same database (set up in `wp-config.php`), but each would get it's own, unique [`$table_prefix`](http://codex.wordpress.org/Editing_wp-config.php#table_prefix).
From there, you can specify [custom user and user meta tables](http://code... |
103,211 | <p>I have created a child theme for a theme I purchased. The purchased theme is for restaurants wanting to display their menu. The theme accepts menu items as Posts, and groups them according to category. The theme only accepts 1 level of categories, not more complex menus with 2 levels of categories.</p>
<p>The pu... | [
{
"answer_id": 104268,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 3,
"selected": true,
"text": "<p>I played with your code a little bit on my local WordPress. I think this should solve your problems.</... | 2013/06/17 | [
"https://wordpress.stackexchange.com/questions/103211",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | I have created a child theme for a theme I purchased. The purchased theme is for restaurants wanting to display their menu. The theme accepts menu items as Posts, and groups them according to category. The theme only accepts 1 level of categories, not more complex menus with 2 levels of categories.
The purchased theme... | I played with your code a little bit on my local WordPress. I think this should solve your problems.
Arguments for your first `get_categories` call, should look like this:
```
$args=array(
'hide_empty'=>false,
'orderby' => 'slug',
'order' => 'ASC',
//'include' => '5, 6, 7, 8', - you don't need to in... |