WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. qzha017
    Member
    Posted 1 year 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

    http://wordpress.org/extend/plugins/wp-favorite-posts/

  2. Huseyin Berberoglu
    Member
    Plugin Author

    Posted 1 year ago #

    it should be like that;

    <?php
    if_(user_logged_in()) {
    wpfp_list_favorite_posts();
    }
    ?>

  3. qzha017
    Member
    Posted 1 year 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>";
            }
        else:
            echo "";
            echo $wpfp_options['favorites_empty'];
            echo "<br><br>";
        endif;
        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
    Member
    Posted 1 year 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
    Member
    Posted 1 year 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.

    Thanks
    Alex

  6. venkmanuk
    Member
    Posted 10 months 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

About this Topic