• Resolved Philljc

    (@philljc)


    Hello. I know how the tags work by themselves, what I’m having trouble with is incorporating them into one area to show info from a specific post ID. This would be the best way to illustrate what I mean:

    http://www.coflash.com/stuff/review.jpg

    Is there a way to do this easily without a plugin? Even then, which plugin would work? If it comes down to me needing to pull info from an unrelated article that links to the review that will also be fine.

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Try it with something like this:

    <?php
    $featured= & get_post( $dummy_id = 834 );
    $featured_url= get_permalink($featured->ID);
    ?>
     <a href="<?php echo $featured_url; ?>" title="<?php echo 'latest review about: '.$featured->post_title; ?>">Latest Review</a>
     <?php if ( has_post_thumbnail($featured->ID)) : ?>
     <a href="<?php echo $featured_url; ?>">
     <?php echo get_the_post_thumbnail( $featured->ID, 'thumbnail'); ?>
     </a>
     <?php endif; ?>
     <a href="<?php echo $featured_url; ?>" title="<?php echo 'latest review about: '.$featured->post_title; ?>"><?php echo $featured->post_title; ?></a>
     <?php
      $excerpt_length = 40;
      $content = $featured->post_content;
      $content = strip_shortcodes($content);
      $content = str_replace(']]>', ']]>', $content);
      $content = strip_tags($content);
      $excerpt = explode(' ', $content);
      if (count($excerpt) > $excerpt_length) {
    	 $excerpt = implode(' ', array_slice($excerpt, 0, $excerpt_length)) . '...';
    	} else {$excerpt = $content; }
    	$excerpt = apply_filters('the_content', $excerpt);
    	echo $excerpt;
    ?>
    <a href="<?php echo $featured_url; ?>" title="<?php echo 'latest review about: '.$featured->post_title; ?>">Read full review</a>

    Change the $dummy_id = 834 to the post ID you want to show.
    and change $excerpt_length = 40; to change the excerpt length

    Thread Starter Philljc

    (@philljc)

    Works brilliantly 🙂

    The only thing is the thumbnail doesn’t seem to show. I’ve activated get_post_thumbnail and I can choose the image, it just doesn’t show up.

    I am putting all of this in a blank sidebar, does it need to be encapsulated in anything to work?

    Thanks again

    Moderator keesiemeijer

    (@keesiemeijer)

    This doesn’t have to be in the loop. The strange thing is that it does work on my testserver. Are you sure your post has a post thumbnail assigned to it.

    Thread Starter Philljc

    (@philljc)

    All good, a restart of XAMPP fixed it for some reason, thanks!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Tags for the following?’ is closed to new replies.