This might work:
add_filter('page_template', 'custom_page_template');
function custom_page_template($template){
// check your permalink here
if(get_query_var('pagename') === 'stories')
return locate_template(array('page2.php', 'page.php'));
return $template;
}
Related Posts:
- How to enable template page only for a post id page
- How Can I Create a Friendly Slug for a Dynamic Page?
- Difference between the_permalink() and get_permalink() function
- Define page template in wp_insert_post
- How to redirect to post if search results only returns one post
- Use author author display name in permalink structure for pages and posts
- Add custom template page programmatically
- Define custom Page Template without its own .php file
- paginate_links() don’t properly work in search.php?
- How to override admin-bar style
- Refresh page after form action
- Filter the query ONLY for the search results page
- Check if a menu is empty?
- wp_get_attachment_image returns different image size
- Passing variables to templates (alternatives to globalizing variables)
- Load post with a different template?
- How to customize search result page title?
- Convert hyphen to underscore in permalinks
- How to fix a theme with page.php Default Template that accidentally deleted?
- WordPress Change Post Templates,but not drop down, but Image selection
- Custom page template how to check is_page from functions.php?
- Returning Variables back into a template
- Using locate-template & shortcodes doesn’t appear to work
- Run Product Filter Javascript On Page Template
- Can I use require() function in a template file?
- How to set global variables in template page?
- Why isn’t is_page_template() adding a body class?
- Dequeue script in template isn’t working
- Programmatically set page template based on page ID
- Query children and parent title
- Help to resolve Syntax error, unexpected ‘endwhile’ (T_ENDWHILE) [closed]
- How to make unique add_filter to the_content of specific page template files – so each template gets its own addition
- Generate permalinks
- How to change menu icon which is overriden (i.e. by WooCommerce) [closed]
- Make “sidebar template” the default template for new pages
- Disable shortlinks like ?p=1234 to prevent scraping
- How to specify which Gutenberg blocks are available in the editor for a page template
- how to change link of some wordpress pages
- Retrieve post modified date for specific post by post ID
- How to get full content including template HTML
- Filtering posts by category name based on page’s slug
- Is there a wordpress function that I can use to retrieve the current page that is loaded?
- Attach parent category template to all subcategories
- Add class or ID to any WordPress function
- How to remove howdy dropdown menu content
- How to include local menu based on page id?
- How to create function from code?
- Display Password Protected external RSS in wordpress template
- How to extract the variables out from “add_shortcode” function?
- Default Gallery Edit/Template Editable?
- Manipulate Permalink
- is_account_page() change to page slug
- Selective Product Category for Carousel
- How to change login labels
- Activate small php condition at footer over page template
- Modify a function without editing template
- Retrieve tags data in post body
- Get_template_part inside a folder
- Functions For Calling Specific Elements
- All top-level pages are using index.php as template
- Full page template function
- How to get correct URLs in network wide menu (Multisite)?
- Where to add the permalink in this function?
- paginate_links() don’t properly work in search.php?
- Changing permalink name redirects to another template?
- How To Load an HTML File As A WordPress Page (With No 301/No Redirect)
- Pass parameter to hooked function using custom page template
- different style sheet for just one page template
- Adding wrapper elements in the_date() like in the_title()?
- wordpress use single ajax in place of multiple ajax requests in a smarter way
- Add Element as a Filter to the_content
- How to fix get_the_category function returning incorrect slug?
- I have problems with loading javascripts
- Pass variable from action back to template
- Need print logo without any ID & class
- Define PHP variable from a seperate API if statement
- Test if a post exists by category and date
- Best way to handle lack of titles in microblogging
- attachment page template? only show attachments for current post?
- Run a jquery script on on a certain template page
- How to include any template using Shortcode fuction?
- How to properly refresh page after form action?
- Image loading function not working on archive.php template
- Add a field into a shortcode of an extension
- How do I create a custom permalink structure for a page template
- Specify multiple categories for custom post template – FATAL ERROR
- Using functions.php to include code that’s processed inline
- How to make a new function that includes a template
- Setting Permalinks in wp_config or functions file?
- Custom permalink structure for remote content pages
- Redirect to post after publish or update a published post
- Page Template Won’t Load Correct CSS File
- Show admin page, only if function is being used
- Overwriting TwentyTwelve template file with child theme template, but lower in the hierarchy
- Prevent creating multiple image resizes in twentytwelve template
- Function to check if custom page is used by page?
- Simplest Way to Build Custom Archives Page?
- Unable to use get_page_by_title() more than once per page?
- Display ACF category image on archive and single template files
- Render page with specific id from functions.php