How to consolidate multiple static page templates into one dynamic one?

Personally, I build everything within index.php of each template. I then do conditional checks. Example: if(is_front_page()){ // Home page layout } elseif(is_page()){ // General page layout if(is_page(‘contact’)){ // Page layout specific to the contact page } elseif(is_page(‘about’)){ // Page layout specific to the about page } } Read more on conditional tags.

Dynamically link to the latest post or simulate request of specific post in page template

You can filter wp_nav_menu_objects and add a new item. Here is a simple plugin doing that: <?php # -*- coding: utf-8 -*- /** * Plugin Name: Latest Post In Menu * Description: Append a link to the latest post to all nav menus called with the argument <code>’add_latest_post’ => TRUE</code>. * Plugin URI: http://wordpress.stackexchange.com/q/59892/73 * … Read more

Check if a menu is empty?

wp_nav_menu has the argument fallback_cb, which is the function called if a menu doesn’t exist. This is set to wp_page_menu by default, which is why you see a list of pages if the menu doesn’t exist. If you explicitly set that to false, then nothing will be output if the menu doesn’t exist. EDIT- Given … Read more

Adding items to page template dropdown on Page Edit Screen

I thought I would provide you with another approach. It is also a bit hackish, but it is general purpose and allows you to simply register the filename and label that you want to use, like so: if ( class_exists( ‘WPSE_196995_Page_Templates’ ) ) { WPSE_196995_Page_Templates::register_page_template( ‘My Page Template’, ‘my-page-template.php’ ); } You could add the … Read more

Ordering Posts List By Taxonomy Terms?

WordPress core (as expressed by involved people on multiple occasions) strongly discourages sort by terms. It sees terms as exclusively grouping mechanism, with no ordering capabilities implied. So in your specific case WP would understand that there are different directors, that there are groups of shows done by those directors, but won’t at all understand … Read more