Templating of a specific post ID

You have to follow this file name structure: single-{post-type}-{slug}.php If you have a post names “Hello World” and the slug of post is hello-world then the template name will be single-post-hello-world.php Update: There is no default way to use id in template name. But you might try this snipped: <?php add_filter( ‘single_template’, ‘load_post_template_by_id’ ); function … Read more

where is the code that executes the template hierarchy?

wp-includes/template-loader.php is the file which is the template hierarchy. However, by the time that file executes, all the template decisions are already made since all that file does is check for boolean flags (defined in wp-includes/query.php function init_query_flags). So all the heavy-lifting and interesting code happens before that at wp-settings.php line 225: $wp_the_query = new … Read more

Load parent theme files before child theme functions.php

The functions.php file executes at plugins_loaded, with the Child Theme functions.php executing before the Parent Theme functions.php. That means that, in order to load functional sub-files in the Child Theme after the Parent Theme functions.php executes, you simply need to hook your include() calls after plugins_loaded. A usually safe action for such purposes is after_setup_theme: … Read more

Load custom template for specific GET parameter

Just found an pretty straightforward solution for this problem: add_action( ‘template_include’, ‘account_page_template’ ); function account_page_template( $template ) { if( isset( $_GET[ ‘account’ ] ) ) { return locate_template( array( ‘account.php’ ) ); } return $template; } But as it seems only natural to use some kind of permalink stucture for these kind of things here … Read more

Rewrite URL for only archive page (custom post type)

You can have a separate slug for the post type archive by setting the slug as the value for the has_archive argument, instead of just true: register_post_type( ‘event’, array( ‘has_archive’ => ‘agenda’, // etc. ) ); Now you can use single-event.php and archive-event.php for the single and archive views, but the URL for the archive … Read more

Change Page Template Based on Category

I’m pretty sure you could also do what you want by filtering template_include. This is super-untested, but maybe this can get you headed in the right direction: function wpse53871( $template ) { global $post; // check if is a Post and in the ‘scott’ category if( is_single( $post->ID ) && has_category( ‘scott’, $post ) ) … Read more

What should I put on my index.php?

index.php is shown whenever wordpress doesn’t find an appropriate page template. Generally people use it as the template for their site’s blog. If you are absolutely sure that it will never be reached, you can leave it empty. Just make sure you have that file present, otherwise the theme will not work As a personal … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)