WP_Query always returning the last custom post
There is no post_name argument for WP_Query, if you’re querying by slug, it’s just name. Without that argument, your query just gets the latest post back.
There is no post_name argument for WP_Query, if you’re querying by slug, it’s just name. Without that argument, your query just gets the latest post back.
Get archive of posts separated by taxonomies and subtaxonomies
You’ve used LIKE comparison method, that means every similar expression will be matched, including exact string and similar string. If you want to match exact string, you should use = operator. Example: global $current_user; $user_roles = $current_user->roles; $user_role_query = array(); for ($i=0; $i < sizeof($user_roles); $i++) { $user_role_query[] = array( ‘key’=>’attribution_roles’, ‘value’ => $user_roles[$i], ‘compare’=>’=’ … Read more
Disabled all plugins and re-enabled only the necessary ones for this plugin to run correctly (a custom-post-types & custom-taxonomies plugin). Re-activated the plugin and got the error message but with a detail that the line 128 had a semicolon in it. As this was a function being called to get the ID of the element … Read more
i think your question has been answered in here $args = array(‘posts_per_page’ => -1, ‘orderby’ => ‘date’ ); $myQuery = new WP_Query($args); $date=””; if ( $myQuery->have_posts() ) : while ( $myQuery->have_posts() ) : $myQuery->the_post(); if ( $date != get_the_date() ) { echo $date; echo ‘<hr />’; $date = get_the_date(); } the_title(); // or whatever you … Read more
Orderby Date and Category
$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘tag’ => $taxonomy, ‘post_type’ => ‘initiative’, ‘paged’ => $paged, ‘posts_per_page’ => 9, ‘category_name’ => $category, ‘tag__not_in’ => array(15), ‘meta_key’ => ‘initative_weight’, ‘orderby’ => array(‘meta_value_num’ => ‘DESC’, ‘title’ => ‘ASC’), ‘post_status’ => ‘publish’ ); I changed tag__not_in to an array and updated the orderby to be … Read more
WP_Query for liked posts is showing all posts if none are liked
You need to pur div container before while loop. Here you go. Here is the modified code and container will have parent page slug class. <?php $args = array( ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘depth’ => 2, ‘sort_column’ => ‘post_name’, ‘post_parent’ => $post->ID, ‘order’ => ‘ASC’, ‘orderby’ => ‘menu_order’ ); $parent = new WP_Query( … Read more
Query posts in current category but not attachment format