Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using Isotope and I currently have each post rendering as a box on my homepage. I am currently trying to edit my (working) query that currently displays all posts with the category slug of 'static'. Within that query i'd like to target 4 specific post ID's and customise the appearance of each of those 4 posts. So each of those 4 posts will have different content to one another. How can I adjust this working loop so that I can add/remove content for 4 different post ID's?

Just to note as well, in my template file, I have another query below this query that displays posts from 6 other categories. The code is the same but I've just changed a link position. I hope that all makes sense!

<?php
            // Query just the category static and make the link manually editable through the 'URL' custom field
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
            $args= array(
                'category_name' => 'static',
                'paged' => $paged
            );
            query_posts($args);
            if( have_posts() ) :?>

            <?php while (have_posts()) : the_post(); ?>

              <?php foreach( get_the_category() as $cat ) echo '<div class="module ' . $cat->slug . '" data-category="' . $cat->slug . '" >'; ?>

                  <a href="<?php echo get_post_meta($post->ID, 'URL', true); ?>" title="<?php the_title(); ?>">
                  <div class="active">
                        <div class="hover"></div>
                        <?php the_post_thumbnail(); ?>
                  </div>

                  <h1><?php the_title(); ?> <span>/ Explode here</span></h1>
                  <?php
                  // Call in the contents of a custom field called Excerpt and if custom field in admin panel is empty don't display <p> tags otherwise wrap contents in <p> tags
                  $excerpt=get_post_meta($post->ID,'Excerpt',true);
                  if($excerpt != '') {
                  echo '<p>'. $excerpt .'</p>';
                  } else {
                  echo ' ';
                  }
                  ?>
                  <p class="date"><!-- for sorting boxes, use post id or date format must be yyyyMMdd--><?php the_time('Ydm') ?></p>
                 </a>
            </div>

            <?php endwhile; ?> 
            <?php endif; ?>
share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

After a bit of digging I came up with this IF statement which solves my problem:

<?php 
                    $flickr_large = 64;
                    $flickr_small = 113;
                    $join = 117;
                    $twtrfeed = 120;
                    if ( $post->ID == $flickr_large ) :  ?>

                            <ul id="cycle"></ul>

                        <?php elseif ( $post->ID == $flickr_small ) : ?>

                            <div id="flickr-wrap"></div>

                        <?php elseif ( $post->ID == $join ) : ?>

                            <p>Join us box - form here?</p>

                        <?php elseif ( $post->ID == $twtrfeed ) : ?>

                            <p>This where the twitter feed will go</p>

                        <?php else : ?>

                            <a href="<?php echo get_post_meta($post->ID, 'URL', true); ?>" title="<?php the_title(); ?>">

                            <div class="active">
                               <div class="hover"></div>
                                <?php the_post_thumbnail(); ?>
                            </div>

                    <?php endif; ?>
share|improve this answer
add comment

Just use post_class() on your post-container element.

// Example:
<div id="post-<?php the_ID(); ?>" <?php post_class('special-class-name'); ?>>

You can the target your specific posts with #post-IDNR in your css/js files.

share|improve this answer
    
Thanks for the response. Surely that only allows me to control style? How would I give each box different content though? For example I need to add a flickr slideshow in one of the boxes and a contact form in another? –  egr103 Mar 15 '12 at 17:53
    
You wrote customise the appearance and not the content... Take a look at my latest answers: "how to style every 3rd post" or similar. –  kaiser Mar 15 '12 at 18:26
    
I did mention different content, "So each of those 4 posts will have different content to one another." Regarding your latest answers, where might I find this? –  egr103 Mar 15 '12 at 18:56
    
Here it is. Oh, and yes, it seems I overread that. –  kaiser Mar 15 '12 at 20:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.