How to Set a Custom Template for Blog Posts

As I understand it, you can’t use Page Templates that way; you need to edit your index.php file instead. See this chart for more detail on how the hierarchy works and this post for a detailed explanation. By specifying “Blog” as the “posts page” on the Settings > Reading tab, you are telling WordPress “this … Read more

Returning Variables back into a template

There’s filters for that. Example: add_filter( ‘template_filter’, ‘wpse_102706_filter_callback’, 10, 2 ); function wpse_102706_filter_callback( $defaults, $case ) { $args = wp_parse_args( array( ‘some_key’ => ‘some_modified_value’ ), $defaults ); return $args } Then in your template just add in the defaults: apply_filters( ‘template_filter’, array( ‘some_key’ => ‘default_val’ ), ‘single’ ); More info in Codex about the Plugins … Read more

Calling a function from functions.php in custom page/ blog post

You could use add_shortcode if you want to use it within the editor. function footag_func() { return “Test”; } add_shortcode( ‘footag’, ‘footag_func’ ); And then use [footag] in your editor. Or Use code like this in functions.php and add a conditional tag add_action( ‘loop_start’, ‘your_function’ ); function your_function() { if ( is_singular(‘post’) ) { echo … Read more

loop not showing up when using a custom page template

You haven’t created a query to return your post index results. Let me back up… In WordPress something called the “Main” query runs very early in the page load, and well before your template files load. That query retrieves the posts to display and also (more or less) determines which template file to use to … Read more