Function to allow single post template based on custom taxonomy?

I think what you’re looking for is the WordPress Template Hierarchy. Basically you can just name the template single-{custom-post-slug}.php and put it in the right directory. Update Now that I understand what you’re actually asking: I bet you could hook {$type}_template, which is called by get_query_template(). It’s expecting a path to the template which has … Read more

WordPress, alternative single post template

You could set a url parameter to change the display so that the URL could be the same, then have your QR code do a pass-through to the desired page. Without knowing how the QR codes are setup and such, I can’t offer much more on high-level implementation than that. The way to switch the … Read more

infinite loop on page with comments after changing comments.php and header.php

The article you’re using is quite old, from ~2009. There are much better cleaner ways of doing commenting. As a guide, follow this: http://ottopress.com/2008/wordpress-2-7-comments-enhancements/ This is the definitive guide to implementing Comments post v2.7, and Otto is widely respected in the community. Firstly, your comments code uses have_posts() to check if there are comments, instead … Read more

Making a wordpress page print friendly

remove_filter( ‘the_content’, ‘printme_add_link’ ) will prevent the link from being placed. You can just call printme_add_link() in your template to generate the print button. Alternately, you can just add_query_arg( ‘print’, 1, get_permalink() ) and use that as the link if you would prefer to do the link some different way.

How to format the first line of a post differently?

Here is the idea add_filter(‘the_content’, ‘testfunc’); function custom_formatter($matches){ return “<strong>{$matches[0]}</strong>”; } function testfunc($content) { $pattern = “$\<p.*\>(.*)\<\/p\>$”; $content = preg_replace_callback($pattern, ‘custom_formatter’, $content); return $content; } However, you will need a better regular expression in $pattern variable as this regex may be very poor. in the custom_formatter function you can do the formattings you want.

Displaying links to all posts of the same category on the post page

I’ve not tested this, but the following is the method you shoulduse. Don’t use query_posts. $cats_of_post= get_the_category(); if($cats_of_post){ $cat_id = (int) $cats_of_post[‘0’]->term_id; $related = get_posts(array( ‘numberposts’ => 5, ‘category’ => $cat_id, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘exclude’ => )); global $post; $temp_post = $post;?> <div class=”related-posts”> <?php if( $related ): ?> <ol> <?php foreach … Read more

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