Hi
I am using YARPP 3.4.2 plug-in.
how can i display related posts only when custom filed is set in a post.
Thanks
~Venkat
http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/
Hi
I am using YARPP 3.4.2 plug-in.
how can i display related posts only when custom filed is set in a post.
Thanks
~Venkat
http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/
Turn off the "automatic display" option, then you can write some code in your theme:
if (check custom field is set here)
related_posts();
HI
Thanks for your responce.Need some more clarification on this.
1. create a custom field by editing the post.
2. Turn off the "automatic display" option under Plugins -->Yet Another Related Posts Plugin --> settings --->display options for your website ---> then uncheck the automaticall display related posts.
After above changes i have written below code in yarpp-template-example.php page.
<?php /*
Example template
Author: mitcho (Michael Yoshitaka Erlewine)
*/
?><h3>Related Posts</h3>
< ?php query_posts('meta_key=review_type&meta_value=movie'); ?>
<?php if ($related_query->have_posts()):?>
<?php endwhile; ?>
<?php else: ?>
<p>No related posts.</p>
<?php endif; ?>
this is the right way to display related posts only when custom filed is set in a post.
I am new to wordpress.Please help me out to resolve this issue.
HI
Thanks for your responce.Need some more clarification on this.
1. create a custom field by editing the post.
2. Turn off the "automatic display" option under Plugins -->Yet Another Related Posts Plugin --> settings --->display options for your website ---> then uncheck the automaticall display related posts.
After above changes i have written below code in yarpp-template-<?php /*
Example template
Author: mitcho (Michael Yoshitaka Erlewine)
*/
?><h3>Related Posts</h3>
<?php if(query_posts(array('meta_key' => 'review_type','meta_value' => 'movie'))):?>
/*<?php if (query_posts('meta_key=review_type&meta_value=movie')); ?>*/
<?php if ($related_query->have_posts()):?>
<?php endwhile; ?>
<?php else: ?>
<p>No related posts.</p>
<?php endif; ?>
this is the right way to display related posts only when custom filed is set in a post.
I am new to wordpress.Please help me out to resolve this issue.
Reply
Message
HI
below code i am using to display related posts only when custom filed is set in a post.
But its not working.Please let me know where i am going wrong.
<?php /*
Example template
Author: mitcho (Michael Yoshitaka Erlewine)
*/
<h3>Related Posts</h3>
<?php if ( get_post_meta($post->ID, 'hide_yarpp', true) ) : ?>
<?php if ($related_query->have_posts()):?>
<?php endwhile; ?>
<?php else: ?>
<p>No custom filed.</p>
<?php endif; ?>
You don't want to do this in a custom template. You want to do this in your your theme's template.
You must log in to post.