Can you call a template file without assigning template to a page in the admin panel?

You can hook into template_redirect like this: function custom_template_redirect() { global $wp; if ($wp->query_vars[‘pagename’] == ‘my-page-slug’) { // check the page slug status_header(200); // a 404 code will not be returned in the HTTP headers if the page does not exists include(TEMPLATEPATH . “/test.php”); // include the corresponding template die(); } } add_action( ‘template_redirect’, ‘custom_template_redirect’ … Read more

wp_title() handling of author page

I see my name in the title when viewing author pages. wp_title() runs this code during execution.. // If there’s an author if ( is_author() ) { $author = get_queried_object(); $title = $author->display_name; } Perhaps your author(s) don’t have a display name set? Additionally be sure to try disabling plugins that may be hooking a … Read more

How to override Category rendering mechanism

if you can use template_redirect hook and a simple function to set the template to use add_action( ‘template_redirect’, ‘category_set_redirect’ ); function category_set_redirect(){ //create the sets of categories $first_set= array(“1″,”2″,”3″,”4″,”5″,”6”); $second_set= array(“7″,”8″,”9″,”10″,”11″,”12”); if (is_category()){ if (in_array(get_query_var(‘cat’),$first_set)){ include(TEMPLATEPATH . “/first_category.php”); // include the corresponding template die(); } if (in_array(get_query_var(‘cat’),$second_set)){ include(TEMPLATEPATH . “/second_category.php”); // include the corresponding template … Read more

Control Custom Post Type template from a plugin

I have got it working by the following code: add_action( ‘template_redirect’, ‘ft_job_cpt_template’ ); function ft_job_cpt_template() { global $wp, $wp_query; if ( isset( $wp->query_vars[‘post_type’] ) && $wp->query_vars[‘post_type’] == ‘job’ ) { if ( have_posts() ) { add_filter( ‘the_content’, ‘ft_job_cpt_template_filter’ ); } else { $wp_query->is_404 = true; } } } function ft_job_cpt_template_filter( $content ) { global $wp_query; … Read more

How to move style from template file to section?

What about putting styles before the function get_header(); <style type=”text/css”>#header { display: none; }</style> <?php get_header();?> <div class=”main-container-of-my-template”></div> <?php get_footer(); ?> However this is not recommended as it loads the styles even before the <html> not within the <head> section of your website, but as per your requirement this could be the only way to … Read more

Use is_category(), is_tag(), … in functions.php

Your problem is that you didn’t wrap it in a callback, but executed it immediately when functions.php was loaded by core. By then the global $wp_query object isn’t initialized fully and the is_category() etc. wrappers can’t deliver what you are expecting them to do. So your if/else checks should be moved inside the callback like … Read more

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