I’m creating a theme at the moment and has come to a point to decide what is the best solution to have implemented for a theme with multiple portfolios.

If there is a project that is in the two of them, and its single page is clicked, where will the Back to Portfolio link points to?

Is there a way for the back button to refer to that portfolio from which the item is viewed?


Doesn’t seem to work correctly because say that the admin has clicked Preview Page on the Single Item admin page, and click Back To Portfolio, it will navigate him back to the admin panel =\

How do you guys deal with items in multiple portfolios?

I can’t wrap my head around it. Any help will be greatly appreciated!


One simple option would be to add a parameter to the query string of the portfolio item (i.e. yousite.com/portfolio-item/?backto=portfolio-3), then on the item page modify the 'back' link with JavaScript: if the backto parameter exists then change the link to point to the portfolio specified in it.

Here's some untested starter code. On the portfolio page (assuming you're looping through portfolio items and printing links to their pages):

<?php $portfolio_name = 'whatever'; ?>
<a href="<?php echo get_permalink() . '?backto=' . $portfolio_name; ?>"><?php the_title(); ?></a>

On the portfolio page:

$key_backto = (isset($_GET['backto']) ) ? $_GET['backto'] : '';
<a href="<?php echo home_url('portfolio/' . $key_backto); ?>">Back to portfolio</a>
  • Oh, um.. can you please add a little code so I can have basic idea how this can be achieved? Do i use add query arg and how? Thanks in advance!
    – Ziik
    Mar 21 '14 at 17:18
  • @Ziik Here you go, this should get you started. Mar 21 '14 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.