Page / Archive Priority
-
Hi folks,
For quite a while (a year at least) I was using pages that were named the same as a base catagory – for example a ‘music’ page that I customised – and these would load instead of the music archive page (music was also a catagory).
I was having problems with my server and the host changed some things and then all of a sudden the archive seemed to take priority over the pages and the pages disappeared.
I’ve used this code below to prioritise page taxonomy but it loads the page template and overwrites the template that I’ve selected when creating each page.
Is there a simple way to define taxonomy priority?
my site is at https://joolsscott.co.uk
currently this code is functioning – but if you look at ‘News’ on my menu it is blank because that uses a ‘timeline’ template in my theme which is being overidden by this code below.
anyone got any ideas?
your help is greatly appreciated.
function loadPageFirst(){// get the actual category $actualCategory = get_category( get_query_var('cat')); // get the page with the same slug $matchingPage = get_page_by_path( $actualCategory->slug ); // If no match, load the normal listing template and exit (edit if you are using a custom listing template, eg. category.php) if(!$matchingPage){ include( get_template_directory().'/archive.php'); die(); } // Make a new query with the page's ID and load the page template query_posts('page_id='. $matchingPage->ID ); include( get_template_directory().'/page.php'); die(); }add_filter('category_template','loadPageFirst');
- The topic ‘Page / Archive Priority’ is closed to new replies.