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

Nest Next and Previous in a href with class that has a background image

EDIT In single.php you should be using: <?php previous_post_link(‘%link’, ‘Previous’); ?> and <?php next_post_link(‘%link’, ‘Next’); ?>. Then you add this to your functions.php: function filter_next_post_link($link) { $link = str_replace(“rel=”, ‘class=”next” rel=”, $link); return $link; } add_filter(“next_post_link’, ‘filter_next_post_link’); function filter_previous_post_link($link) { $link = str_replace(“rel=”, ‘class=”prev” rel=”, $link); return $link; } add_filter(“previous_post_link’, ‘filter_previous_post_link’); Although this is not … Read more

Links in the_content not linked

Running make_clickable on the_content will get you your links. So… apply_filters(‘the_content’,’make_clickable’); … in your functions.php should link your content. It will be simple but you should get hyperlinks. I don’t see a way to add the target=”_blank” part. make_clickable is in wp-includes/formatting.php. You could use it as a pattern for a function that would add … Read more

Attachment image single page

Refer to the Template Hierarchy for attachment post types: `$mimetype.php $attachment.php single-attachment.php single.php index.php So for an image attachment, name your template file image.php. Then, to link to the single post view for an attachment, you would link to it like any other post: get_the_permalink( $postid ).