• _MattCapper_

    (@_mattcapper_)


    Hey,

    I am trying to hide a category of posts from an otherwise nice ‘recent posts’ widget that came with my theme and is displayed in the sidebar when you are looking at another post.

    So basically I have located the widget’s .php file and have found this piece of coding – which I think is dictating which posts are being displayed in the recent posts section:

    Global $posts;
    $args = array(
    ‘post_type’ => ‘post’,
    ‘numberposts’ => $number,
    ‘orderby’ => $order,
    ‘no_found_rows’ => true,
    ‘meta_key’ => ‘_thumbnail_id’,
    ) ;

    I want to exclude category 4 and I want category 3, 6 and 7 to be shown.

    So I put in:

    ‘cat’ => ‘3’,
    ‘cat’ => ‘6’,
    ‘cat’ => ‘7’,

    Under ‘post_type’ => ‘post’ like this:

    Global $posts;
    $args = array(
    ‘post_type’ => ‘post’,
    ‘cat’ => ‘3’,
    ‘cat’ => ‘6’,
    ‘cat’ => ‘7’,
    ‘numberposts’ => $number,
    ‘orderby’ => $order,
    ‘no_found_rows’ => true,
    ‘meta_key’ => ‘_thumbnail_id’,
    ) ;

    This did exclude the category I wanted but seemed to make the widget more static as it never changed the posts shown as it is set to display random posts.

    So basically, does anyone know how I can do this without affecting the widgets overall functionality?

    I’d appreciate it as I have never done coding before so my knowledge is basic and I have done everything so far by trial and error. I can’t seem to find a reasonable explanation on forum sort he internet as I have for everything else so far.

    My site is http://www.worldtravelbubble.com in case you need to see what I mean.

  • The topic ‘Hiding a category from a 'recent posts' widget’ is closed to new replies.