WordPress.org

Ready to get started?Download WordPress

Forums

Duplicate widget and make small changes (3 posts)

  1. jpdeboer
    Member
    Posted 3 years ago #

    In this theme I have a sidebarwidget, that shows news from newscategories I can fill in. Now I want the same, but then for portfolio-categories.

    I found this permanent solution:

    Open up sidebar_news.php and find this line:
    $additional_loop = new WP_Query("cat=".$cat."&posts_per_page=".$count);

    Change it to:

    $additional_loop = new WP_Query("post_type=portfolio&cat=".$cat."&posts_per_page=".$count);

    Still I can not get this to work. Unfortunately also this is a permanent solution and I am looking to make both possible.

    Also this was said:

    If you want to use the Sidebar News widget for the blog entries and for the portfolio entries you need to duplicate the widget or change it's code (more complex). I would create an extra portfolio news widget based on "Sidebar News" widget. Currently it's not possible to show both post types.

    Now I tried duplicating the widget and change things so I see it in the widget area, but no luck.

    Anybody any idea how to get a copy of this news-widget?

  2. Mr Brainz
    Member
    Posted 3 years ago #

    Are portfolio-categories and newscategories actual categories or custom post types?

    In your code, setting a post_type is for setting a custom post type. If it's a category then you could use 'category_name' to pull the posts by the category slug.

    Also not sure where you're pulling your $cat and $count vats from.

    Are you outputting this new query with $additional_loop->the_post() anywhere?

    It's worth having a read over this http://codex.wordpress.org/Function_Reference/WP_Query

  3. jpdeboer
    Member
    Posted 3 years ago #

    @Mr Brainz:

    Are portfolio-categories and newscategories actual categories or custom post types?

    How can I tell?

Topic Closed

This topic has been closed to new replies.

About this Topic