Multiple portfolios and single item in two of them (ideas?)

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?

Read More

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

$back =$_SERVER['HTTP_REFERER']

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!

Related posts

Leave a Reply

1 comment

  1. 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>