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

Specify what to do for a specific image number of the post

set a counter variable outside the foreach, check its value in each iteration and output corresponding markup, then increment it at the end for the next iteration. <?php $images = get_post_meta($post->ID, ‘rw_postpage_images’); // set a counter $image_counter = 1; foreach ($images as $att) : $src = wp_get_attachment_image_src($att, ‘full’); $src = $src[0]; $image_path = thumbGen($src,80,80,”crop=1&halign=center&valign=center&return=1″); // … 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

Display X images from a gallery in the sidebar

Sounds like you need a custom query in order to pull X amount of images. You could do the following (untested): <?php function custom_gallery_display( $number_of_images = 4 ) { //make sure you have access to the WPDB object global $wpdb; //pull 4 random attachments $images = $wpdb->get_results(“SELECT ID from wp_posts WHERE post_type=”attachment” ORDER BY RAND() … Read more

Not being allowed to use some terms in Add New Site in WordPress

http://codex.wordpress.org/Create_A_Network#Permalinks /blog cannot be used as a new site name. It is relied on heavily by WP for the main site. Everything added to it automatically has /blog as part of the permalink from my understanding You can check out this discussion http://wordpress.org/support/topic/root-directory-blog-for-wordpress-30-main-multisite to see if it helps you out, gives some further options. The … Read more