Photos-For-You.com update (26 of 1373 or so..)
After much faffing around.
I finally found the following post :-
http://www.wprecipes.com/how-to-show-related-posts-without-a-plugin/
And plucked up the courage to merge some YAPB code and the above and add it to my single.php file to get YAPB thumbnails appearing on my 'Related Posts'.
Here is what it looks like now :-
How it decides on which posts are related, and how is displays the thumbnails and titles isn't quite perfect yet, but I am 90% happy with this!
Total time spent = approx 1 hour. (Should have done this yesterday and saved myself 4 hours of messing around - but you live and learn...)
For anyone else who is struggling to get YAPB thumbnails coming up in the related posts automatically - here is what my single.php file now looks like :-
<?php
/**
* The Template for displaying all single posts.
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
get_header(); ?>
<div id="primary-post">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<nav id="nav-single">
<span class="nav-previous"><p><?php previous_post('%', '<< Previous Post - ', 'yes'); ?> <?php next_post('%', '>> Next Post - ', 'yes'); ?></p></span>
<?php sharebar(); ?>
</nav><!-- #nav-single -->
<?php get_template_part( 'content', 'single' ); ?>
<?php
//for use in the loop, list 5 post titles related to first tag on current post
$tags = wp_get_post_tags($post->ID);
if ($tags) {
echo '<strong>Related Photos</strong><div style="clear:both;">';
$first_tag = $tags[0]->term_id;
$args=array(
'tag__in' => array($first_tag),
'post__not_in' => array($post->ID),
'showposts'=>6,
'caller_get_posts'=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<div style="float:left;width:120px;border:1px solid #d8d8d8;margin:0 6px 6px 0;padding:3px;"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title();
echo yapb_get_thumbnail(
'<div>', // HTML before image tag
array(
'alt' => 'Photo thumbnail', // image tag alt attribute
'rel' => 'lightbox' // image tag rel attribute
),
'</div>', // HTML after image tag
array('w=120', 'q=90'), // phpThumb configuration parameters
'thumbnail' // image tag custom css class
);
?>
</a></div>
<?php
endwhile;
}
}
?>
<div style="clear:both;">
<?php comments_template( '', true ); ?>
<?php endwhile; // end of the loop. ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>
Follow Money From Photos on Twitter | Click Here To Subscribe To My RSS Feed | Click Here To Subscribe To Feed By Email
I finally found the following post :-
http://www.wprecipes.com/how-to-show-related-posts-without-a-plugin/
And plucked up the courage to merge some YAPB code and the above and add it to my single.php file to get YAPB thumbnails appearing on my 'Related Posts'.
Here is what it looks like now :-
How it decides on which posts are related, and how is displays the thumbnails and titles isn't quite perfect yet, but I am 90% happy with this!
Total time spent = approx 1 hour. (Should have done this yesterday and saved myself 4 hours of messing around - but you live and learn...)
For anyone else who is struggling to get YAPB thumbnails coming up in the related posts automatically - here is what my single.php file now looks like :-
<?php
/**
* The Template for displaying all single posts.
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
get_header(); ?>
<div id="primary-post">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<nav id="nav-single">
<span class="nav-previous"><p><?php previous_post('%', '<< Previous Post - ', 'yes'); ?> <?php next_post('%', '>> Next Post - ', 'yes'); ?></p></span>
<?php sharebar(); ?>
</nav><!-- #nav-single -->
<?php get_template_part( 'content', 'single' ); ?>
<?php
//for use in the loop, list 5 post titles related to first tag on current post
$tags = wp_get_post_tags($post->ID);
if ($tags) {
echo '<strong>Related Photos</strong><div style="clear:both;">';
$first_tag = $tags[0]->term_id;
$args=array(
'tag__in' => array($first_tag),
'post__not_in' => array($post->ID),
'showposts'=>6,
'caller_get_posts'=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<div style="float:left;width:120px;border:1px solid #d8d8d8;margin:0 6px 6px 0;padding:3px;"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title();
echo yapb_get_thumbnail(
'<div>', // HTML before image tag
array(
'alt' => 'Photo thumbnail', // image tag alt attribute
'rel' => 'lightbox' // image tag rel attribute
),
'</div>', // HTML after image tag
array('w=120', 'q=90'), // phpThumb configuration parameters
'thumbnail' // image tag custom css class
);
?>
</a></div>
<?php
endwhile;
}
}
?>
<div style="clear:both;">
<?php comments_template( '', true ); ?>
<?php endwhile; // end of the loop. ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>
Follow Money From Photos on Twitter | Click Here To Subscribe To My RSS Feed | Click Here To Subscribe To Feed By Email
Make Money From Photos by Jordan McClements is licensed under a Creative Commons Attribution-Non-Commercial-No Derivative Works 3.0 Unported License.


0 comments:
Post a Comment