Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

PHP & Wordpress

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

PHP & Wordpress

Postby BorisDollar » Thu Sep 27, 2012 12:06 pm

Hi, i'm new here and probably a bit out of my depth with PHP. I'll try to explain my problem as best as I possibly can.

I have a Wordpress theme which has a section for creating a portfolio. I have populated the portfolio with various images, and the images are split into categories. For arguments sake, lets call them Category1, Category2, Category3 (all the way up to Category7).

The portfolio also has a filter which allows the user to select "Category2" and then only images in Category2 will be shown. Nothing too clever there.

However, I had to split the portfolio into 2 separate portfolios, quite simply because I have too many categories to filter. So to cut a long story short, I have 2 portfolios. Portfolio1 contains categories1/2/3/4/5 and Portfolio2 contains categories6/7.

This works fine, except for the filter. Lets take Portfolio2 for example. It correctly only shows images in Category6 and Category7. But the filter at top has all the categories listed there, when really I only want the filter to show Category6 and Category7. I've pinpointed the code in portfolio.php that controls these filters and this is what it is:

Code: Select all
<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>


So the code above shows filters for all categories. How can I show filters for just the 2 categories?

Your help would be much appreciated.

Thanks.
BorisDollar
New php-forum User
New php-forum User
 
Posts: 2
Joined: Thu Sep 27, 2012 11:53 am

Re: PHP & Wordpress

Postby kyle04 » Thu Sep 27, 2012 1:38 pm

You may need to look at the function get_terms(), which seems to control the base output.
kyle04
New php-forum User
New php-forum User
 
Posts: 94
Joined: Sat Jul 07, 2012 1:36 pm

Re: PHP & Wordpress

Postby BorisDollar » Thu Sep 27, 2012 2:53 pm

Thanks. Exactly the sort of direction I needed. will take a look at the 'portfoliocategory' to see whether it can be adapted.
BorisDollar
New php-forum User
New php-forum User
 
Posts: 2
Joined: Thu Sep 27, 2012 11:53 am


Return to PHP coding => General

Who is online

Users browsing this forum: Google Feedfetcher and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.