lost css when overriding themes templates

Without seeing the code, I would guess that your main stylesheet is being loaded by get_stylesheet_directory_uri() or something of that nature. Now that you’ve copied header.php into your child theme get_stylesheet_directory_uri() is looking in YOUR theme for that stylesheet. It isn’t there and thus you have no CSS. Change the stylesheet directory to get_template_directory_uri() and … Read more

Template files for Custom Post Type and Taxonomy

The way taxonomies work with rewrites, is that they have a ‘slug’. Look at the codex under register_taxonomy, you will see the ‘rewrite’ argument. Supply it with array( ‘slug’ => ‘properties/location’ ) and refresh your permalinks. Otherwise, it’s looking for the following: mysite.com/property_location/office-space Refer to @vancoders answer for the template solution.

How can template identify what page it’s being used on?

Idea #1 is correct if your template use body_class() like <body <?php body_class(); ?>> In this case the body tag will be something like: <body class=”page page-id-6 page-template-default”> If the id of viewed page is 6 and template used is the default. See Codex However, in pages the global $post variable is available even in … Read more

How to make the first widget box to be closed instead of open in admin

This is hardcoded and cannot be changed, the first sidebar box is the only one that doesn’t receives a closed CSS class. You’d have to use jQuery to do it: add_action( ‘admin_footer-widgets.php’, function(){ ?> <script type=”text/javascript”> jQuery(document).ready(function($) { $(‘#widgets-right .widgets-holder-wrap:first’).addClass(‘closed’); }); </script> <?php }); There’s a small glitch because the box appears opened at first … Read more

Is template name always same as directory name?

According to the codex The Template is the directory name of the parent theme … If you want to make a child of a theme with the directory name example-theme-name, then you would use Template: example-theme-name. So yes its always the name of the parent theme directory.

Can I have both front-page.php and index.php?

When a theme has the front-page.php template, it will take over regardless of what you set in the admin pages to be your front page. 1 This means you have a couple of options: Create a page template with your loop and styles that are currently part of front-page.php, apply that template to a new page … Read more

Add filter multiple times using only one master function

Use a use statement: add_filter( ‘single_template’, function ( $template ) use ( $name ) { Or just pass all templates at once, and create just one function: add_filter( ‘single_template’, function ( $file ) use ( $templates ) { global $post; if ( in_array ( $post->post_type, $templates ) ) return __DIR__ . “/{$post->post_type}.php”; return $file; });

Get URL of current post but not the page number

I don’t think your code works as expected because you are not printing the URL of the post. Note that get_permalink() returns the permalink of current post inside a loop but doesn’t print it like the_permalink(). So, you should use <?php echo get_permalink(); ?> or <?php the_permalink(); ?>.

WordPress 3.9 not using custom template

Since I don’t have your theme I can’t find what causing this problem, but this should definitely solve your problem for now Create content-{post_type}.php file and add your custom-post. in the index.php add the below code above <?php get_template_part( ‘templates/content’, ‘format’); ?> <?php if(!in_array(get_post_type(), array(‘post’, ‘page’, ‘attachment’, ‘nav_menu_item’, ‘revision’))) ?> <?php get_template_part( ‘content’, get_post_type()); ?> … Read more