WordPress.org

Ready to get started?Download WordPress

Forums

Show only post in category widget (1 post)

  1. Final_Alpha
    Member
    Posted 1 year ago #

    Hi,
    I want to change this in the widget to show only a list of posts of a certain category:

    ...
    if ( is_home() || is_page()  ) {
                if (!empty($postList)) {
                    echo "<div class='container'><div class='cpost'><ul>";
                        foreach ($postList as $obj) {
    
    ***
    if ( in_category('8') ) { echo "test";
    } else { echo "not"; }
    ***
    
    $idlink = $obj->ID;
    $luplink = get_permalink($idlink);
    ...
    echo "<a href=".$luplink." title='{$obj->post_title}' class='dark_perm'>
    ...
    } } }

    But "in_category doesn't work", how can make the list to show only posts of category 8?

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic