How does WordPress choose archive type template?

WordPress uses a Template Hierarchy to determine which template file to load based on the current context: This diagram is a visual representation of \wp-includes\template-loader.php, that contains the context-based template-selection logic. As to your specific questions: For example, suppose I have two posts by the same author. How do I make WP use the author.php … Read more

page-{slug}.php vs. template-{slug}.php

So my question is, should I assume that this is a theme-based functionality, where some themes provide support for files with the template-{slug}.php naming? Correct. Or do all WordPress applications allow for such files? If so, where can I find instructions on how to use template-{slug}.php files? Or is there another way these days to … Read more

Best practice to update the file header.php

This question leans towards getting some subjective answers, as I think it’s a matter of personal preference. The built-in editor works just as well as any other text editor. That goes for any of your theme files, not just header.php. The benefit of using an external editor (like Notepad++ and using FileZilla to FTP your … Read more

Possible to have one template call different sidebars for different pages?

If you’re using static pages, try using is_page() for your conditionals. Let’s assume your static pages have slugs, “customers”, “vendors”, and “services”: <?php if ( is_page( ‘customers’ ) : get_sidebar(‘customer’); elseif ( is_page( ‘vendors’ ) ) : get_sidebar(‘vendors’); elseif ( is_page( ‘services’ ) ) : get_sidebar(‘services’); else : get_sidebar(); endif; ?> But I agree with … Read more

How do I override the search template in a plugin?

You can use template_include filter hook add_filter(‘template_include’,’my_custom_search_template’); function my_custom_search_template($template){ global $wp_query; if (!$wp_query->is_search) return $template; return dirname( __FILE__ ) . ‘/my_search_template.php’; } /*UPDATE: there was a missing “;” after $template*/

How can I force URL of a custom post type archive to use a page template?

You can pass a string for has_archive. That string will be used as archive URL. So in your registration code use: ‘has_archive’ => ‘jobs’ From the register_post_type() declaration in WordPress core: if ( $args->has_archive ) { $archive_slug = $args->has_archive === true ? $args->rewrite[‘slug’] : $args->has_archive; if ( $args->rewrite[‘with_front’] ) $archive_slug = substr( $wp_rewrite->front, 1 ) … Read more

URL / Templating system advice [closed]

Do you have: A category somecategory defined? Posts categorized with somecategory? Some default else: content in the Loop in category.php? I suspect the URL is returning a 404, and WordPress is simply serving up the root URL, because it has no content to serve up from category.php. EDIT You don’t need to do anything special … Read more

Where is Number of Posts Set?

That looks like a http://para.llel.us/support/ theme. You might start there for docs—for instance, they probably have a custom ‘Theme Options’ page in the admin. Short of that, and presuming you’re ok with setting it in code (which may negate any future settings in the admin), you’ll first need to find out where $blog_query is being … Read more

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