get_query_var(‘paged’) giving same result
get_query_var(‘paged’) giving same result
get_query_var(‘paged’) giving same result
I would recommend using content-{posttype}.php method, where you only have HTML markup, template tags for posts or custom post types and leave loops outside of those files. See Twenty Eleven for more detailed example. After this change you can easily modify search.php and include specific content markup based on post type. if ( have_posts() ) … Read more
Huh. I double-checked. On my local server, this bit of code successfully changes the post: function test_redirect() { global $wp_query; $wp_query->set(‘page_id’, 5); } add_action(‘pre_get_posts’, ‘test_redirect’); You’re going to have to do a bit of debugging. On a dev server, var_dump the $wp_query variable a few key places to check that it has what you expect … Read more
I’ve solved the problem myself though it is probably not be the right way to do it. Note that I’ve had to type “website-address” instead of the actual URL because system here won’t let me use more than one URL in a post without more reputation. That makes it quite difficult to convey what’s actually … Read more
The function cat_is_ancestor_of takes two arguments (two category IDs). To check if category of ID 61 is ancestor of category with 54: cat_is_ancestor_of(54,61); I’m not sure if there is a better way of doing this, but you can get the current category’s ID with the get_queried_object() and then check this an ancestor of the category … Read more
Assuming you stick with add_rewrite_rule(), if language and title where set as meta data on the /en/ post, then you can simplify the search down to a simple WP_Meta_Query() for /:lang/:title/ and pull the actually ID of the translated post there. Translations for /en/best-restaurants-in-tokyo: “/it/migliori-ristoranti-a-tokyo” => 4016 “/fr/meilleurs-restaurants-à-tokyo” => 4017
To find projects happening within a range of dates, there are 3 cases you have to account for: A project starts within the range A project ends within the range A project starts before the range and ends after the range You can test for these 3 cases separately with an OR meta query and … Read more
Try the below $args instead, the one you have right now is looking for liked_by_user_id > than the current user id. $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1, ‘orderby’ => ‘date’, ‘meta_query’ => array( array( ‘key’ => ‘liked_by_user_id’, ‘value’ => get_current_user_id() ) ), ); The above $args should return all posts by liked … Read more
I finally found some helpful information in this post: How to “Load More” posts via AJAX? The issue ended up being a combination of counting the number of total pages of posts, and sharing that number with the hooked ajax function in functions.php. Here’s my page template loop: <div class=”events”> <?php $socal_cats = array( ‘Los … Read more
WordPress creating excessive joins on meta_query with search