Set WordPress Default Template

The better, cleaner solution would be not to use custom page templates to define page layouts*, but rather to use custom post meta to define page layouts. To implement: Create a Theme Option for Default static page layout, that includes all possible page layout options Create a _page_layout custom post meta for Page Layout, that … Read more

Calling widget via function in themes files (hard code)

Using the_widget() is the correct way to “hard code” an arbitrary Widget in a template file: <?php the_widget( ‘foobar_widget’, $instance, $args ); ?> Since the_widget() simply returns if ‘foobar_widget’ is not a registered Widget, it is functionally equivalent to using an if ( function_exists( $function ) ) conditional. You could look in core to see … Read more

variables in translatable text

The translation strings not only get parsed during rendering (output on screen/in browser), but also by the GNU gettext parser. This one is not a PHP parser, so it can’t fetch variables. This is the only part of a Theme or a Plugin, where you need to repeat yourself and add the plain string to … Read more

Animated gif for a thumbs

To use gifs in WordPress you need to insert the full size of the uploaded gif (the original size). In the Media Box : Size: Full Size Any other size you choose will not render because of how GD crops and re-sizes the photos, it does so by taking a single frame, to make it … Read more

How does a Child Theme works?

You are correct, that WordPress will load the style.css file from your parent theme first, and then the style.css from your child theme. These means because of how CSS itself works, you have to specifically override any rule you wish to override. What this means is that you would need to modify the CSS within … Read more

How can I let templates choose which stylesheets are enqueued?

Check the current template in your callback. This is a post meta field named _wp_page_template. add_action(“wp_enqueue_scripts”, function() { // This stylesheet is used on *every* page wp_register_style(“sitewide”, get_template_directory_uri() . “/assets/sitewide.css”); wp_enqueue_style(“sitewide”); if ( ! is_singular() ) return; $template = get_post_meta( get_the_ID(), ‘_wp_page_template’, TRUE ); // now enqueue further stylesheets depending on the current template });

How to remove comment link title attribute?

The title attribute is hard-coded in comments_popup_link() unfortunately: echo ‘ title=”‘ . esc_attr( sprintf( __(‘Comment on %s’), $title ) ) . ‘”>’; What you can do is catching the generated HTML in a variable and replacing the attribute with an empty string: ob_start(); comments_popup_link(); print preg_replace( ‘~ title=”[^”]+”~’, ”, ob_get_clean() );