This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Portfolio item Mini Post Grid sidebar custom queries

  • Creator
    Topic
  • #17292
    mike-se
    Participant

    I’m getting some sort of conflict I can’t seem to figure out. I’m using the portfolio plugin. The setup is like this:

    Layout: Sidebar right.

    Several portfolio items with featured images in two portfolio categories: portfolio-category-1 and portfolio-category-2.

    Two custom widget areas (sidebar right): portfolio-1 and portfolio-2. Each with its own custom query:

    "portfolio_item" == get_post_type() || is_tax("portfolio-category-1")
    "portfolio_item" == get_post_type() || is_tax("portfolio-category-2")

    Both widget areas have the Mini Post Grid widget with custom queries:

    post_type=portfolio_item&portfolio=portfolio-category-1&numberposts=16
    post_type=portfolio_item&portfolio=portfolio-category-2&numberposts=16

    This wont work. The sidebar will only show one of the widget areas no matter what portfolio item I’m on. If I remove the custom query from the widget area that is showing it will show the other one.

    Is the setup wrong, conflicting queries or perhaps a bug?
    How do I do this?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Author
    Replies
  • #17297
    Jason Bobich
    Keymaster

    Hello Mike,

    So, on the portfolio items single posts, you’re trying to display two separate widget areas in the right sidebar at the same time? Do I understand it right?

    If so, this won’t be possible because a widget area location on a page can never have more than one widget area. The whole way the system works is to search for a widget area until it finds a match for that location. Once a match is found, it stops. There is no where in the backend of how it works where multiple widget areas could be stored. In other words it’s looking for a single ID of a widget area to fill that slot.

    This is why when you’re making various assignments under Appearance > Widget Areas, I put the green checkmarks to signify that there is no conflict with any other assignments for a location. It works in most cases, but it’s not perfect. This is an example, when using custom queries, that nothing will alert you there’s a conflict at Appearance > Widget Areas.

    Another approach you could take, though, is to use the widget logic plugin:

    https://wordpress.org/plugins/widget-logic/

    Within your single widget area (i.e. portfolio sidebar), you can place conditionals individually for each widget.

    #17308
    mike-se
    Participant

    Hi Jason,

    Thanks for your answer. Didn’t know about widget logic. Seems awesome. So I have been fiddeling around with it and simply can’t get it to work here. I have now one widget area with two widgets. In the widget locig fields I put these:

    widget 1:

    is_tax( 'portfolio_item',  'portfolio-category-1' )

    widget 2:

    is_tax( 'portfolio_item',  'portfolio-category-2' )

    Nothing.

    If I try this:

    widget 1:

    'portfolio_item' == get_post_type() || is_tax( 'portfolio_item',  'portfolio-category-1' )

    widget 2:

    'portfolio_item' == get_post_type() || is_tax( 'portfolio_item',  'portfolio-category-2' )

    Both widgets show.
    This:

    widget 1:

    is_single() && is_tax( 'portfolio_item',  'portfolio-category-1' )

    widget 2:

    is_single() && is_tax( 'portfolio_item',  'portfolio-category-2' )

    Nothing again. Any help much appreciated.

    #17309
    Jason Bobich
    Keymaster

    Hmm, well “portfolio_item” is the id of the post type, not the taxonomy. The ID of the taxonomy is “portfolio” — So, when you’re targeting the portfolio archive page, it should be:

    is_tax( 'portfolio',  'portfolio-category-1' )

    And when you’re targeting the portfolio item single post page, it should be:

    'portfolio_item' == get_post_type()

    Does that work?

    #17311
    mike-se
    Participant

    It’s like ” is_tax ” does nothing at all. If I only have:

    is_tax( 'portfolio',  'portfolio-category-1' )

    it should at least show the widget on the single page, right? Nothing.

    If I type:

    'portfolio_item' == get_post_type()

    it shows both widgets.

    and if I type:

    'portfolio_item' == get_post_type() || is_tax( 'portfolio',  'portfolio-category-1' )

    nothing again.

    #17313
    Jason Bobich
    Keymaster

    Are you sure you’re meaning to use is_tax? From what you’re describing, it sounds like maybe there is some confusion about this conditional, possibly? This would never be true on the single post page. The is_tax conditional will be true only on the Taxonomy archive page only. Other than, I’m just not sure here.

    #17314
    mike-se
    Participant

    Thanks Jason,

    I’ll investigate further on this. So would there be any other way to solve this problem using Jump Start?

    The idea is this. Two or more illustrators want to showcase their work in a portfolio. In the sidebar on a single portfolio (project) page (which might include several images) they want to show only their own work, from their respective portfolios?

    I’ll send you the site url as private info.

    #17320
    Jason Bobich
    Keymaster

    So I think that was it; you’re misunderstanding what is_tax() is for. —

    This conditional is true if you’re on a taxonomy archive page only. None of the pages you linked me to are taxonomy archive pages; it looks like you’re only dealing with sidebars in the portfolio item single posts. I think you’re thinking that is_tax() means “is IN taxonomy term” — which is not the case, if that makes sense.

    On your site, this would be an example of a taxonomy archive page, where is_tax() would be true:

    http://yoursite.com/items/your-portfolio/

    A individual portfolio item would be:

    http://yoursite.com/item/your-portfolio-item/

    Note the difference of “items” vs “item”.

    I think what you want is:

    has_term( 'your-portfolio', 'portfolio' )

    … I don’t think in this case you’d even need to have a condition for the post type, as it would not be possible for a post to have term from “portfolio” taxonomy, if it were not one of your portfolio items.

    http://codex.wordpress.org/Function_Reference/has_term

    #17321
    Jason Bobich
    Keymaster

    And it’s very simple, but your child theme is looking really nice on that site!

    #17322
    mike-se
    Participant

    Thanks Jason!

    has_term( ) worked instantly, ofcourse.

Viewing 9 replies - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.