You can add a query string to your URLs and read that using the $_GET
global.
For example, you could add ?template=main
to your posts’s URL. Then, in the single-cpt.php for your CPT, use
<?php if ( isset( $_GET['template'] ) ) $mytemplate = $_GET['template']; ?>
Then, around the bits that you want to display differently, just add
switch ( $mytemplate ):
case "main":
//code;
break;
case "somethingelse":
//code;
break;
default:
//code;
endswitch;
Oh, and to add the query string to your URLs in the first place, use:
$url = add_query_arg( 'template', 'main', $permalinktopost );
Hope that helps
Related Posts:
- Custom post type single-{custom}.php not working
- Disable single pages and archives and keep preview
- How to check the terms in single custom post type template
- How do I display tags for a custom post type single page?
- Not Able To Render Single-CustomPostType.php File
- single-{post_type}.php not working
- Get term name without a foreach loop
- How can I write slugs / permalinks as: custom post type -> custom taxonomy and custom post type -> custom taxonomy (one CPT and many taxo)?
- get_the_terms child terms for current post/custom post only
- Making permalink for custom post type/custom taxonomy. Stuck with 404 in the single post
- Display Taxonomy Term for CPT on single-CPT.php
- How to display category wise posts on seprarate template
- Custom Taxonomy as checkbox or dropdown
- Custom Taxonomy as Dropdown in admin
- WP insert post and custom taxonomy
- Custom Post type in separate database table for syncing
- WP_List_Table Inside Metabox Not Working on Submit
- Creating Photo Gallery System with Custom Post Type
- Custom Taxonomies Terms as Post Title for Custom Post Types upon Publishing
- How to filter post data with AJAX on page?
- Custom permalinks
- Separate Custom Post Type Taxonomy by Comma
- Maintaining WP_Query Relation Among CPT, Custom Taxonomy, Permalinks- CPT UI
- Add filter to wp_list_categories and query what type of taxonomy-terms it use?
- Custom post type category, taxonomy and URL rewrite problem
- Get child terms of current term of the current post
- Allow duplicate slugs for posts on Custom post type in different categories/taxonomy?
- Assign category to front end post
- Custom Post Type: How to display all of same taxonomy?
- Is there any performance consideration when using Custom Post Types?
- Taxonomy structure of Sport site
- Custom post type custom taxonomy archive page name
- Querying Term Posts in Loop
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- Permalinks not working for custom taxonomy on custom post type
- I have 2 post types i need to show the post type contents in 2 select boxes [closed]
- Display Recently Added Custom Post Types with Custom Taxonomy Shortcode
- How can I set taxonomy programmatically
- Return the latest post from a custom Taxonomy and Post Type
- Don’t know how to show custom taxonomies from a custom post_type
- Single template showing all posts of that type
- WordPress loop: Show only a Custom Post Type Taxononmy TERM
- Dynamic dropdown select values depending on other custom field value
- Full Custom Post Type List Organised by two Taxonomies
- URL rewriting for CTP assigned entity
- Query Custom Post Type Taxonomy term with multiple parameters
- How to group posts and get a mixed posts and groups view?
- Post format alternative?
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- dropdowboxes with pre-selected custom fields optios that filters the results according seach needs
- Control content before and after custom post type loop
- post_type_link Filter – Too Few Arguments
- Rewrite custom post type with taxonomy
- Show categories of custom post type and not all posts
- how to count the current posts terms
- Reusable metabox backend and frontend
- Get A Custom Field From A Custom Taxonomy Of A Custom Post Type [closed]
- Using page title as a link to term archive
- Add custom post type taxonomy tag to article class
- How to display posttypes and taxonomy in standard posts, not in a separate label?
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- Creating custom post type and taxonomy archives and pretty URLs
- Should i use custom post type for a custom footer?
- best way to use custom taxonomy, post type and meta in a job system
- Show 10 newest post for each value of a custom taxonomy
- Display the link of a custom taxonomy
- Custom taxonomy: on the taxonomy term page show other taxonomy terms
- Error 404 change permalink term custom term taxonomy
- How to display custom post type taxonomy in Contact Form 7 text field
- Custom Post Type & Taxonomies – Rewrite
- Custom post categories are not displaying on the page
- get_posts wont produce a list of custom type from a given category [duplicate]
- CPT tags not showing when editing post
- PHP Warning with Custom Fields
- Don’t share custom taxonomy terms if applied to multiple Custom Post Types
- How to show custom post count in archive page
- How to add independent “Tags” to Custom Post Type?
- Display custom tax in “while” loop
- Show posts under a selected custom taxonomy term
- Linking Taxonomies
- Get posts under custom taxonomy and custom post type
- Flush rewrite rules when new cpt is registred
- Shortcode in excerpt
- How do I retrieve the title of a term of a custom post type with custom taxonomies?
- Show custom taxonomy not in submenu
- Custom Taxonomy is disabled on Edit page
- Excluding top level from taxonomy and post loop
- Custom Post Type and Custom Taxonomy not connected
- Get a list of categories ids
- How to Associate Posts with Pages
- Get link for feed of specific post type AND taxonomy
- Get single object term for custom taxonomy
- Sorting custom post types by taxonomy (So close)
- Custom posts and custom taxonomies for many products and categories?
- How to retreive terms associated with a custom post type?
- Return Custom Post Type Categories
- Create taxonomy from Custom Post Type
- ACF Relationship: Group posts by parent category term, then child [closed]
- Create a hierarchical list of posts that’s grouped and nested by category
- Show a wordpress custom post condtionally using a category term