Programmatically change post templates? [duplicate]

Try this: while ( $query->have_posts() ) : $query->the_post(); if ( has_tag(‘tag-slug’) ) { get_template_part( ‘content’, ‘tag-slug’ ); } else { get_template_part( ‘content’ ); } endwhile; You would then need to create content.php and content-tag-slug.php with the appropriate content. You could also look into setting up Post Formats. A bit more work up front, but a … Read more

Change default comments form title [duplicate]

Please be clear for what u need to ask. As i approach to your query.you should first login to your admin panel.now click on appearance and then click editor option.here comes all the files of your theme directory.Look for comment.php. Just open it up and look for default message.Now this is the place where you … Read more

PHP Puzzle: Unique Styles with PHP loop

To are still call database inside the by get_post_meta() where you already have the values in $custom_fields variable. Try something like this: <?php $custom_fields = get_post_custom($post->ID); for ($i = 1; $i <= 4; $i++) { if(isset($custom_fields[“rw_location_$i”][0])){ if($i==1){ echo ‘<h1>’;} else {echo ‘<h2>’;} echo $custom_fields[“rw_location_$i”][0] if($i==1) {echo ‘</h1>’; }else {echo ‘</h2>’}; } } ?> If I … Read more

Show post thumbnail only if it exists using timthumb

As commented above, you don’t have to use TimThumb at all to get additional image sizes for your uploaded images. WordPress ships with the add_image_size() function. // functions.php add_action(‘init’, ‘wpse26655_add_additional_image_sizes’); function wpse26655_add_additional_image_sizes() { add_image_size(‘thumb200x120’, 200, 120, true); } In your template files, you could than query your thumbnail with your desired image size. E.g. <?php … Read more

Fix My Custom Function: Remove Automatic

If I’m understanding your question correctly, I think adding remove_filter( ‘the_excerpt’, ‘wpautop’ ); around when you have add_filter(‘excerpt_length’, ‘Excerpt::new_length’); does what you’re looking for.