[COLOR=#101094][FONT=Consolas]function[/FONT][/COLOR][COLOR=#303336][FONT=Consolas] loadPageFirst[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]()[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]{[/FONT][/COLOR][COLOR=#858C93]// get the actual category[/COLOR][COLOR=#303336]
$actualCategory [/COLOR][COLOR=#303336]=[/COLOR][COLOR=#303336] get_category[/COLOR][COLOR=#303336]([/COLOR][COLOR=#303336] get_query_var[/COLOR][COLOR=#303336]([/COLOR][COLOR=#7D2727]'cat'[/COLOR][COLOR=#303336])[/COLOR][COLOR=#303336]);[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#858C93]// get the page with the same slug[/COLOR][COLOR=#303336]
$matchingPage [/COLOR][COLOR=#303336]=[/COLOR][COLOR=#303336] get_page_by_path[/COLOR][COLOR=#303336]([/COLOR][COLOR=#303336] $actualCategory[/COLOR][COLOR=#303336]->[/COLOR][COLOR=#303336]slug [/COLOR][COLOR=#303336]);[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#858C93]// If no match, load the normal listing template and exit (edit if you are using a custom listing template, eg. category.php)[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]if[/COLOR][COLOR=#303336](![/COLOR][COLOR=#303336]$matchingPage[/COLOR][COLOR=#303336])[/COLOR][COLOR=#303336]{[/COLOR][COLOR=#303336]
include[/COLOR][COLOR=#303336]([/COLOR][COLOR=#303336] get_template_directory[/COLOR][COLOR=#303336]()[/COLOR][COLOR=#303336].[/COLOR][COLOR=#7D2727]'/archive.php'[/COLOR][COLOR=#303336]);[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]die[/COLOR][COLOR=#303336]();[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#303336]}[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#858C93]// Make a new query with the page's ID and load the page template[/COLOR][COLOR=#303336]
query_posts[/COLOR][COLOR=#303336]([/COLOR][COLOR=#7D2727]'page_id='[/COLOR][COLOR=#303336].[/COLOR][COLOR=#303336] $matchingPage[/COLOR][COLOR=#303336]->[/COLOR][COLOR=#303336]ID [/COLOR][COLOR=#303336]);[/COLOR][COLOR=#303336]
include[/COLOR][COLOR=#303336]([/COLOR][COLOR=#303336] get_template_directory[/COLOR][COLOR=#303336]()[/COLOR][COLOR=#303336].[/COLOR][COLOR=#7D2727]'/page.php'[/COLOR][COLOR=#303336]);[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]die[/COLOR][COLOR=#303336]();[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#303336]}[/COLOR][COLOR=#303336][FONT=Consolas]add_filter[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]([/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]'category_template'[/FONT][/COLOR][COLOR=#303336][FONT=Consolas],[/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]'loadPageFirst'[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]);[/FONT][/COLOR]