New answers tagged

0

Your code should work, it might be that your posts per page option in back end is set to 1. It would be beneficial to explicitely set posts_per_page in your query args. You can also make the code faster if you only need to know the amount of grandchild posts, you can just return the post ids's. Here is an example: (Copied and modified from your code) $...


1

Use wp_list_pluck to extract an array of IDs from your query, then pass those to is_page. $top_level_ids = wp_list_pluck( $top_level_pages, 'ID' ); if ( is_page( $top_level_ids ) ) { // do something }


1

Even though the recommendations have been updated to: To run WordPress we recommend your host supports: PHP version 5.6 or greater MySQL version 5.6 or greater OR MariaDB version 10.0 or greater the minimum requirements are not there yet: WordPress server requirements for Version 3.2+: PHP version 5.2.4 or greater MySQL ...


0

There is date_query which can handle this and an SQL query is not a good practice when you can take advantage of WordPress Query API: $pid = 1; // post ID here $args = array( 'posts_per_page' => -1, 'post_type' => 'post', 'date_query' => array( array( 'year' => get_the_date('Y', $pid), 'month' => ...


0

Notice: caller_get_posts is deprecated since version 3.1! Use ignore_sticky_posts instead.


0

'LIKE' isn't supported by the current version of WP_Tax_Query, so you'll need to write a custom query. This answer from a couple of years ago still seems to be the best approach: http://wordpress.stackexchange.com/a/133805/26317.


0

I've finally solved this problem. I'm copying the code because it may help someone :) I've found the solution by populating an arrray and checking if a brand is or is not there, so I only get each brand one time. <?php //Query to match department $args = array( 'tax_query' => array( array( 'taxonomy' => '...


1

2 choices here, you either need to set the category as an array e.g. $args = array( 'posts_per_page' => 5, 'category' => array(15,16,17,18,19) ); You can't just add the numbers in a list but I can't find any documentation that the category element allows multiples (as the name is category) The other option is to use wp_query and category__in $...


1

You have a problem in the array construction. You have that : $args = array( 'posts_per_page' => 5, 'category' => 15, 16, 17, 18, 19 ); And you probably need that : $args = array( 'posts_per_page' => 5, 'category' => [15, 16, 17, 18, 19] );



Top 50 recent answers are included