WordPress.org

Ready to get started?Download WordPress

Forums

Yet Another Related Posts Plugin (YARPP)
[Plugin: Yet Another Related Posts Plugin] yarpp.3.4.2 - display related posts only when custom file (6 posts)

  1. venkat123
    Member
    Posted 2 years ago #

    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/

  2. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 2 years ago #

    Turn off the "automatic display" option, then you can write some code in your theme:

    if (check custom field is set here)
    related_posts();

  3. venkat123
    Member
    Posted 2 years ago #

    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 while ($related_query->have_posts()) : $related_query->the_post(); ?>

    1. " rel="bookmark"><?php the_title(); ?><!-- (<?php the_score(); ?>)-->
    2. <?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.

  4. venkat123
    Member
    Posted 2 years ago #

    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 while ($related_query->have_posts()) : $related_query->the_post(); ?>

    1. " rel="bookmark"><?php the_title(); ?><!-- (<?php the_score(); ?>)-->
    2. <?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

  5. venkat123
    Member
    Posted 2 years ago #

    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 while ($related_query->have_posts()) : $related_query->the_post(); ?>

    1. " rel="bookmark"><?php the_title(); ?>
    2. <?php endwhile; ?>

    <?php else: ?>
    <p>No custom filed.</p>
    <?php endif; ?>

  6. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 2 years ago #

    You don't want to do this in a custom template. You want to do this in your your theme's template.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic