WP Favorite Posts
display the actual favourites list on custom page (6 posts)

  1. qzha017
    Posted 3 years ago #

    I know I can add a new specific page and put in {{wp-favorite-posts}} but I need to display the list of my saved favourites on specific page, say profile or home page (only if I was logged in)

    what's the code to call the list into the profile.php and home.php to list the favourites?

    Thanks everyone


  2. Huseyin Berberoglu
    Plugin Author

    Posted 3 years ago #

    it should be like that;

    if_(user_logged_in()) {

  3. qzha017
    Posted 3 years ago #

    Thanks I will give it a try.

    But how do I show the post excerpt and thumbnail if the favourites?
    I came across solveigm's post but it wasn't working for me the code he gave out is

    echo "";
        if ($favorite_post_ids):
    		$favorite_post_ids = array_reverse($favorite_post_ids);
            foreach ($favorite_post_ids as $post_id) {
                $p = get_post($post_id);
                echo "<div class='post'><div class='entry'>";
    						echo "<a href='".get_permalink($post_id)."'>";
    						echo get_the_post_thumbnail ( $post_id, 'thumbnail', array('class' => 'alignleft'));
    						echo "</a>";
                echo "<h3><a href='".get_permalink($post_id)."' title='". $p->post_title ."'>" . $p->post_title . "</a></h3> ";
                echo $p->post_excerpt;
                echo "<br><br>";
              	echo wpfp_remove_favorite_link($post_id);
              	echo "</div></div>";
                echo "<br>";
            echo "";
            echo $wpfp_options['favorites_empty'];
            echo "<br><br>";
        echo "";

    in the wpfp-page-template.php-file, I have done the same but no excerpt is showing, I also saw another post saying I need to make a call the my functions.php

    Can you help me to get the exerpt showing?

    Thanks Huseyin!

  4. solveigm
    Posted 3 years ago #

    For the excerpt to show, you must have written something in the excerpt-window in the post-editor. It doesn't produce automatic excerpts from your text.

  5. qzha017
    Posted 3 years ago #

    Thanks for responding solveigm

    so there is no way to call and display the wordpress generated excerpt <?php the_excerpt(); ?> in the favourites?

    I have not written any excerpt in all my post as I thought WP can generate them automatically, and I can alter it in many ways.


  6. venkmanuk
    Posted 3 years ago #

    you could try to trim the text down to, say, 20 words to generate an auto-excerpt. here's a snippet i use a lot:

    // add to functions.php
    function custom_field_excerpt($title) {
    			global $post;
    			$text = get_field($title);
    			if ( '' != $text ) {
    				$text = strip_shortcodes( $text );
    				$text = apply_filters('the_content', $text);
    				$text = str_replace(']]>', ']]>', $text);
    				$excerpt_length = 20; // 20 words
    				$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
    				$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
    			return apply_filters('the_excerpt', $text);
    /// then use <?php echo custom_field_excerpt('field_name'); ?>

    By the way... i can't get this plugin to generate a list of favorite posts. is it working for you with the latest WP version? // edit, it was a custom post type problem. fix was here: http://wordpress.org/support/topic/favorite-in-custom-post-type-not-working?replies=4

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Favorite Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic