WordPress.org

Ready to get started?Download WordPress

Forums

Related Posts for WordPress
PHP code for Template add Custom Field (8 posts)

  1. FammentiGrafici
    Member
    Posted 2 years ago #

    This plugin is very nice, but has little documentation.
    This is a help in getting started ...
    php code in the template with the addition of custom field
    recovered from the pages related.

    <?php
    	$related_posts = MRP_get_related_posts($post->ID,false, true, 'yourPostType');
    	foreach($related_posts as $key => $value) {
    	$related_post = get_post($key);
    	$custom_field = get_post_meta($related_post->ID, 'yourCustomField', true);
    
    	echo get_the_post_thumbnail($related_post->ID, 'thumbnail');
    	echo '<br>';
    	echo $related_post->post_title;
    	echo '<br>';
    	echo $related_post->post_content;
    	echo '<br>';
    	echo get_permalink($related_post->ID);
    	echo '<br>';
    	echo $custom_field;
    	echo '<br>';
    	echo '<hr>';
    	}
    ?>

    http://wordpress.org/extend/plugins/microkids-related-posts/

  2. Deminoodle_be
    Member
    Posted 2 years ago #

    Must this piece of code be place inside the loop?

    Thanks ;-)

  3. FammentiGrafici
    Member
    Posted 2 years ago #

    Yes ... inside the loop!

  4. Deminoodle_be
    Member
    Posted 2 years ago #

    Aweome! Thanks bro!

    Finally a plugin who does the 'thing' I need ;-)

  5. Deminoodle_be
    Member
    Posted 2 years ago #

    Is there any way to get the_excerpt from a related post?

    Or maybe to truncate only the the text of the content?

    Thanks!

  6. FammentiGrafici
    Member
    Posted 2 years ago #

    Have you tried with $related_post->the_excerpt; ??

    or

    PHP SUBSTRING ( substr )

  7. Deminoodle_be
    Member
    Posted 2 years ago #

    Seems to work with $related_post->post_excerpt;

    Thanks for your help ;-)

  8. FammentiGrafici
    Member
    Posted 2 years ago #

    :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic