WordPress.org

Ready to get started?Download WordPress

Forums

Category Filter in Portfolio (9 posts)

  1. borisdollar
    Member
    Posted 1 year ago #

    I have 2 portfolios. One with 5 categories, and the other with 2 categories. However, with the code below, all categories are filterable on each portfolio, when really what I want is filters for category 1 to 5 for portfolio 1 and categories 6 & 7 for portfolio 2. I've pinpointed the code below in portfolio.php, but can't seem to get it to work. Its either all filters or nothing!

    To make it easier to understand, lets just call the categories:

    category1
    category2
    category3
    etc etc

    <h2><a class="catlink" href="#filter=*"  rel="nofollow">Show All</a>
        <?php $categories = get_terms("portfoliocategory");
        foreach ($categories as $category) {
          $entrycategory = str_replace(',','',str_replace('.','',$category->name));
          echo '<a class="catlink" href="#filter=.'.$entrycategory .'"  rel="nofollow">'.$category->name.'</a>';
        }
        ?>
        </h2>

    Thanks so much.

  2. Exactly what theme are you talking about? Many themes have "portfolios," and some themes are actually called Portfolio.

  3. borisdollar
    Member
    Posted 1 year ago #

    Its a purchased Radial theme. Basically the portfolio & filters work fine. But I have too many categories, so decided to split the portfolios into two separate ones.

    Because of this, the two portfolios originally included exactly the same content, but I was able to include / exclude certain categories so that categories 1-5 are shown in portfolio 1 and categories 6&7 in portfolio 2.

    So far, so good.

    The filter allows the user to select "category1" and only portfolio items registered to that category will show. However, the filter on both portfolios shows all categories, when I don't want it too. The code above (in my original post) is definitely the right area.

    The theme has lots of normal pages but one section is simply for adding portfolio items.

    Hope you can help!

  4. You're using a premium/paid theme. It's best to go to the support site where you bought the theme. These forums are only for free and WordPress/Automattic released themes.

  5. borisdollar
    Member
    Posted 1 year ago #

    Oh damn, sorry. I thought I could get support here if the question was generic.

    Assuming portfolio filters are achievable on some free themes, then perhaps there might be someone on here that can help.

    I'd imagine for someone who understands PHP, this would be easy (maybe i'm wrong!)

    Premium support costs a fortune and I'm not in any position to do that.

    I appreciate your response though.

  6. Custom themes by nature won't be generic.

    Premium support costs a fortune and I'm not in any position to do that.

    Well, sometimes that's what happens with a paid theme; the support isn't cheap or good.

  7. borisdollar
    Member
    Posted 1 year ago #

    I'm still trying to work this out, several days later. I wonder if there is anyone on here that can point me in the right direction?

    Cheers.

  8. kittersa
    Member
    Posted 8 months ago #

    Hello @borrisdollar did you manage to figure this out?

    I'm having the exact same problem and It's driving me insane

    Cheers,

  9. borisdollar
    Member
    Posted 8 months ago #

    Hi Kittersa.

    Its a while back so i'm not 100% sure I can remember, but I do recall it being very "manual" labour.

    So first I duplicated the portfolio so that I had portfolio1 and portfolio2.

    In portfolio1 I set up the filters:

    <a class="catlink" href="#filter=*" rel="nofollow">Show All</a>
    <a class="catlink" href="#filter=.Cat1" rel="nofollow">Cat1</a>
    <a class="catlink" href="#filter=.Cat2" rel="nofollow">Cat2</a>
    <a class="catlink" href="#filter=.Cat3" rel="nofollow">Cat3</a>
    <a class="catlink" href="#filter=.Cat4" rel="nofollow">Cat4</a>
    <a class="catlink" href="#filter=.Cat5" rel="nofollow">Cat5</a>

    Next up we have to select which categories are actually queried:

    query_posts("showposts=$showposts&post_type=portfolioentry&paged=$paged&portfoliocategory=cat1,cat2,cat3,cat4,cat5");

    The categories queried can be listed in any order. Be very careful with slugs etc as a capital letter can really mess things up!

    So now all we have to do is the repeat all of the above in the 2nd portfolio, making sure you change the filter categories and queried categories to suit your needs.

    Hope that helps!

Topic Closed

This topic has been closed to new replies.

About this Topic