WordPress.org

Support

Support » How-To and Troubleshooting » Show only post in category widget

Show only post in category widget

  • 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

  • The topic ‘Show only post in category widget’ is closed to new replies.
Skip to toolbar