• Resolved warend2

    (@warend2)


    Hello guys, I need your help. I want to hide the latest post, if the post category is matched to the category of What’s New post.

    I have separates of WP_Query functions one is for the What’s New and the others are for the specific categories like Gadgets, Sports, Business etc..

    If the What’s New post is under the category of Gadget, on the gadget category area must hide the latest post or add offset -1 on the loop.

    The purpose of this is to prevent duplication of my posts.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter warend2

    (@warend2)

    I have just found the solution by my self. I used global and set the variable to Category ID of the Latest Post. And if the ID is match to the latest post’s Category ID add the offset = 1.

    It works for me.

    Thread Starter warend2

    (@warend2)

    I am having a problem on parent category. Can any one check if this script of mine is worked for you?

    $catidarry = in_array(5,95);
    if($hidecatid==$catidarry){
    $args = array(
    ‘cat’ => 5,
    ‘post_status’ => ‘publish’,
    ‘ignore_sticky_posts’ => 1,
    ‘posts_per_page’ => 1,
    ‘offset’ => 1
    );
    }else{
    $args = array(
    ‘cat’ => 5,
    ‘post_status’ => ‘publish’,
    ‘ignore_sticky_posts’ => 1,
    ‘posts_per_page’ => 1
    );
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide latest post when category matched’ is closed to new replies.