Support » Themes and Templates » [Resolved] Recent Posts Exclude Category

[Resolved] Recent Posts Exclude Category

  • Hello,

    I’m making own theme to my website. I’m in trouble with codes.

    I want to recent 4 or 5 posts in all posts exclude one category.

    My code is;

    $id = get_cat_id(‘portfolyo’);
    $q = “cat=-“.$id;
    query_posts($query_string . $q); ?>

    <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>

    <?php endwhile; ?>

    I put some code below, above my code, nothing is happen;

    $args = array( ‘numberposts’ => ‘2’ );
    $recent_posts = wp_get_recent_posts( $args );

    Thanks in advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’d tried $recent_posts codes couldn’t merge with my codes.

    Any help please?

    I’d tried to page them except recent 4-5 posts showing.

    I couldn’t have the right view.

    Is there any help, please?

    At last, I solved the question. This is the answer.


    $recentPosts = new WP_Query();

    $id = get_cat_id(‘portfolyo’);
    $q = “cat=-“.$id;

    $recentPosts->query(‘showposts=5&cat=’ .$q);

    while ($recentPosts->have_posts()) : $recentPosts->the_post();

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Recent Posts Exclude Category’ is closed to new replies.
Skip to toolbar