WP_Query doesn’t works inside loop

try like this: if ($obj->have_posts()){ while($obj->have_posts()){ $obj->the_post(); $slug = get_the_tags(); $obj->the_title(); echo “<br/>”; $queryH = array(“cat”=>13,”order”=>”ASC”,”posts_per_page”=>-1,”tag__in”=>$slug); $objH = new WP_Query($queryH); if ($objH->have_posts()){ while($objH->have_posts()){ $objH->the_post(); $objH->the_title(); echo “<br/>”; } } } }

WordPress text field in array problem

It looks like you may be creating an array around a single long string that needs to be split up into array elements (assuming $idsposts is a string and not an array). Try using $myposts = explode(“,”, $idsposts); Instead of just adding $idsposts as the only element of your $myposts array. You can also check … Read more

WP_Query Not Working with Variable

I’m pretty sure it’s because you’ve got mixed nested quotes when you’re setting $CatIDsCode. So this should fix it: $camp_posts_bynumber = new WP_Query (array (‘cat’ => $CatIDs)); P.S. Move $CatIDs= implode(‘,’, $out); outside of the foreach loop. 🙂

Help displaying related categories

Replace wp_get_post_tags($post->ID); with wp_get_post_terms($post->ID); All parameter and details can be found here and change the $args parameter $args = array( ‘category__in’ => array($simlar_tag), ‘post__not_in’ => array($post->ID), ‘posts_per_page’ => 3, ‘meta_query’ => array(array(‘key’ => ‘_thumbnail_id’, ‘compare’ => ‘EXISTS’)), ‘ignore_sticky_posts’ => 1, ); Hope it works!

date_query problem

You’re looking for the get_adjacent_post function. This is a built-in wordpress function that you can use to get either the previous or next post from the current post. To get the next post: $next_post = get_adjacent_post( false, ”, false, ” ); To get the previous post: $prev_post = get_adjacent_post( false, ”, true, ” ); You … Read more

make query more simplest and in one query

You can try this <?php $args= array( “post_type” => array(“product”, “post”, “page”), “cat” => ‘-124,-52’, “meta_query” => array( array( “key” => ‘include_newsletter_feed’, ‘value’ => “”, ‘compare’ => ‘!=’ ), ), ); $wp_query = new WP_Query($args); ?>