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="https://wordpress.stackexchange.com/questions/138758/<?php echo get_permalink() ."?backto=' . $portfolio_name; ?>"><?php the_title(); ?></a>
On the portfolio page:
$key_backto = (isset($_GET['backto']) ) ? $_GET['backto'] : '';
<a href="https://wordpress.stackexchange.com/questions/138758/<?php echo home_url("portfolio/' . $key_backto); ?>">Back to portfolio</a>
Related Posts:
- Force WordPress to only match URL in category
- CPT Efficient way to display posts from different categories with custom query
- Custom Taxonomies in body class with parent slug
- Custom Post Type categories at edit post not hierarchical
- Multiple archives for cpt, taxonomies, terms
- YearWise Categorywise Post
- How to Fix WordPress 500 Internal server error due to custom post type
- Custom post type with custom taxonomy permalinks
- Custom taxonomy in custom post type archive with pagination
- Same permalink structure for all post types?
- Best way to group posts based on custom post type terms
- Hide Custom Taxonomy title if not associated with another Custom Taxomony
- How to display category wise posts on seprarate template
- Get archive of posts separated by taxonomies and subtaxonomies
- Custom post type AND custom taxonomy are not connected
- Query Pulling the same post twice
- template structure for CPT not clear
- Dropdown switching subcategories portfolio
- Multiple post types or single post type with category taxonomy?
- How to add base permalink to custom posts?
- Cannot retrieve Custom Taxonomies (Disappeared)
- Add a meta to custom post type which corresponds to a particular taxonomy
- Custom Post type and Taxonomy in post URL error
- Is it possible to add and display custom post types to an array?
- Complex strcuture as CPT or taxonomy for use in woocommerce product variations [closed]
- Custom post type and custom taxonomies display
- WP_Query for CPT with filter by another WP_Query
- Display Custom taxonomy, Child terms and posts in a template Under Specific Parent terms
- Get posts in same category not working
- Heirarchical URLs with CPT and custom taxonomy
- Custom taxonomy page template
- Displaying taxonomies with manage_{custom-post-type}_posts_custom_column
- How do I put `tax_query` in this WP_query?
- WordPress custom post type advise
- Custom Post Type and Taxonomies, creating the corresponding template file and loop the data
- Generating a radius search on postmeta-metavalue and adding a taxonomy to query
- WordPress Custom taxonomy template
- Plugin Error on activating
- Associate custom categories to different user IDs
- Get posts associated with custom taxonomy alternate way
- Hierarchical taxonomy in permalink structure
- How to create default taxonomy term for a custom post type? [duplicate]
- Can I create a taxonomy term that mirrors the name of a new custom post?
- Rewrite for custom type and custom taxonomy
- Extensive search filtering and results->PDF in the front-end
- How to pass taxonomy terms to WP_Query along with $args?
- How to create TEMPLATES for TAXONOMIES? What I have to change in this code?
- Custom Post Status & Taxonomies
- Display custom Taxonomies same as listing Categories
- redirect old post type url to new structure url
- How can I add a “fake” parent into the permalink?
- Custom post type taxonomy not sorting correctly
- WordPress custom post type
- How to have working breadcrumbs with several taxonomies associated with a custom post type
- Get list of CPT posts in *current* post’s taxonomy term
- Organizing The Custom Post Type with Taxonomies / Parent Posts
- show custom taxonomies in hierarchy
- Loop with Custom Post Type and Taxonomies
- Pagination fault in custom post type archive page [duplicate]
- Display 2nd category, only once, as sub-heading, in the loop
- Custom Post Types and Pre Populated Custom Taxonomies
- Render custom taxonomy query as single template
- Custom meta-box for all custom post types
- Custom Taxonomy Query by Taxonomny not working
- WordPress: insert a custom post type instance as an option for a custom taxonomy
- Fetch posts list from fist CPT taxonomy term and list under 2. CPT
- How to solve performance issue caused by custom post type overview with 20k+ custom taxonomy terms
- Single page archive – get coresponding taxonomy and terms
- How to assign custom post template to its custom taxonomy terms
- Excluding top level from taxonomy and post loop
- Prevent repetitive terms in get_the_term_list
- Trouble showing showing Posts related to custom post type and taxonomy.
- One custom post type with two different url structure base on taxonomy term
- How to query posts by meta keys AND under specific category?
- Displaying posts exclusively in their category (not parent)
- Loop multiple taxonomy in custom post
- Shortcode display CPT Query only showing 1 post?
- wp_query: How to retrieve current term slug in custom taxonomy?
- Get custom taxonomy name from custom post
- Custom taxonomy archive is visible to only subscibed users
- Post Editor: display categories from current post type taxonomy only?
- Custom Post Type and Custom Taxonomy not connected
- tax_query showing no results
- Add different meta box based on taxonomy
- List all posts from custom post type by taxonomy
- Permalinks when using Custom Post Type with static page for archive
- How to List CPTs Under One Tax Term
- How to change permalinks to taxonomy and post type’s posts
- Generating List of Tags from Custom Post Type
- predefined custom field on registration page
- Post data in separate divs with incrementing class using WP_Query
- Displaying taxonomy icon outside archive page
- Why won’t this rewrite rule work?
- archive-{custom_post_type}.php not getting recognized wordpress
- Paginate custom taxonomy category with wp_custom_pagination
- Archive.php is not displaying tags
- How to retrieve the permalink for a specific (custom) term?
- Values inside a custom field to determine which category posts to display
- Custom post type post taxonomies
- Custom Taxonomy List, Selection floats to top