• I want to show one post and featured image of current category by tag (latest of current category by tag), it works but show the post on parent category also and in the child category, I just want to show only in the current category but affect the parent category, I have the next code:

    <?php $current_category = single_cat_title("", false); $category_id = get_cat_ID($current_category); $cat_posts = new WP_Query( 
    
    array( "showposts" => "1",
           "tag" => "principal",
           "cat" => "$category_id"
        ) );
    while($cat_posts->have_posts()) : $cat_posts->the_post(); $do_not_duplicate[] = $post->ID; ?>

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

Viewing 1 replies (of 1 total)
  • Thread Starter checog0

    (@checog0)

    Sorry, I got it to works, I change

    "cat" => "$category_id" by "category__in" => array(get_query_var("cat"))
    
    <?php $current_category = single_cat_title("", false); $category_id = get_cat_ID($current_category); $cat_posts = new WP_Query( 
    
    array( "showposts" => "1", 
    
               "tag" => "principal", 
    
    		   "category__in" => array(get_query_var("cat")),
    
        ) );

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

Viewing 1 replies (of 1 total)
  • The topic ‘Show post by tag of current category’ is closed to new replies.