WordPress.org

Ready to get started?Download WordPress

Forums

WP Favorite Posts
Thumbnail and exerpt in favorite page view / blog look (19 posts)

  1. solveigm
    Member
    Posted 1 year ago #

    Hi,

    I'd love the user's favorite page to have more of a blog or portfolio look, but I'm a novice when it comes to php. Can anyone help me out with one or more of these? (and where to paste the code)

    Here's what I'd like:

    1. No bullet list
    2. Thumbnail of post either above or to the left of the post title
    3. Show exerpt
    4. Two or three columns
    5. Buttons instead of plain links for add/remove

    ...or maybe I should just look for a different plugin?

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

  2. solveigm
    Member
    Posted 1 year ago #

    Solved most of this by editing the wpfp-page-template.php-file.
    This code does the following:
    - Removes bulleted lists
    - Shows post title as h2
    - Shows thumbnail to the left
    - Shows excerpt of post

    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 "";

    Also, I figured a way to display buttons instead of text links, but it requires that your theme has button shortcodes. I'm using Striking by Kaptlin Themes, and did the following in the settings page:

    - Select "No Image" as icon
    - Paste <div title="Add to favourites" class="button medium green"><span>Add to favourites</span></div> in "Text for add link"-field
    - Do the same for the other fields. My theme supports different color and size buttons.

    Additionally, I added a "Go to my favourites"-button next to add and remove, simply by pasting the following code after the </div> tag in the add/remove fields:
    <a href="your url" class="button medium white"><span>Go to my favourites</span></a>

    No all I need is to arrange the favourites in columns. Any suggestions?

  3. qzha017
    Member
    Posted 1 year ago #

    Hi solveigm
    Thank you so much for sharing the solution as I was looking for the exact answer for a few days now. The code you gave above for some reason dosen't show the post excerpt do you know why? How do I show <?php the_excerpt(); ?> in the /wpfp-page-template.php?

    Thanks very much for your help
    Alex

  4. talha8877
    Member
    Posted 1 year ago #

    Hey qzha017,
    Unless you write something to the excerpt field in the post page nothing shows up. If you want to generate automatic excerpts there are more than enough plugins for that.

    @solveigm Thanks you so much for sharing your solution

  5. lildragn
    Member
    Posted 1 year ago #

    Thanks very much solveigm, your solution worked great!

  6. lildragn
    Member
    Posted 1 year ago #

    Hi solveigm, quick question, do you know if it's possible to change the order the favorites are listed? Right now it lists the oldest to newest. Might be more trouble than it's worth, but thought I'd ask :)

  7. solveigm
    Member
    Posted 1 year ago #

    I would imagine you could change 'array_reverse' to just 'array' to list them new to old. See below where in my code I mean.

    Don't take my word for it though, I'm still no expert! But as far as I can tell, you won't do any harm by testing it.

    echo "";
        if ($favorite_post_ids):
    		$favorite_post_ids = array_reverse($favorite_post_ids);
  8. lildragn
    Member
    Posted 1 year ago #

    Ok so taking out the reverse will return nothing. So from what I gathered regarding this command is that we're basically telling the array as stated to reverse itself once we have it. All that we have to do it remove this line

    $favorite_post_ids = array_reverse($favorite_post_ids);

    And the list will then go from latest favorited :)

    Cheers!

  9. lildragn
    Member
    Posted 1 year ago #

    Oh btw if you wanted, you can add a simple count to your list by simply using

    <?php echo count($favorite_post_ids, COUNT_RECURSIVE);?>

  10. Tech4Eleven
    Member
    Posted 1 year ago #

    anyway to show post content instead of excerpt? using

    <?php echo apply_filters('the_content', $post->post_content); ?> instead of your echo $p->post_excerpt; but it doesnt show anything. any help is appreciated.

  11. Tech4Eleven
    Member
    Posted 1 year ago #

    Oh btw if you wanted, you can add a simple count to your list by simply using

    <?php echo count($favorite_post_ids, COUNT_RECURSIVE);?>

    this works great except it shows 1 post is added when there's no posts added, in chrome anyway. for some reason, IE and FF work great. Noticed this on the cookie warning too - doesnt display in chrome only.

    I wish when you clicked "remove all" or whatever you have on your favorites page, that it would refresh the page and clear your favorites.

    BTW, I am using v 1.5.6 because 1.5.8 doesnt work for me.

  12. Elektra3
    Member
    Posted 1 year ago #

    Thanks so much, solveigm for you code! thumbnails displaying as they should! :)

    Now one more dilemma - does anyone yet have a solution to having a column view as opposed to vertical list for favorite posts??

  13. Tech4Eleven
    Member
    Posted 1 year ago #

    Elektra3, im using a column layout but its built into my theme. I know I've seen many articles on creating such a layout.

  14. Elektra3
    Member
    Posted 1 year ago #

    Tech4Eleven, are you able to point me into the right direction? I'm quite new at this and not sure how to incorporate solveigm solution with column layout...? would be forever grateful! :)
    Is it a matter of changing php or as simple as CSS?

  15. Elektra3
    Member
    Posted 1 year ago #

    Tech4Eleven, I think I've found the solution using my theme's inbuilt columns layout and modifying "post" div class :D seems to be working!

    Thanks so much for your help and pointing me in the right direction! :)))

  16. Tech4Eleven
    Member
    Posted 1 year ago #

    cool.

  17. lildragn
    Member
    Posted 1 year ago #

    Hi again, I'll like to expand on this further by introducing a pagination type function or even a 'load more' type feature. I've accumulated 30 favorites currently on my page and the list is getting a tad long :). Has anyone implemented anything like this? Would be a great addition.

    Thx!

  18. aptharsia
    Member
    Posted 1 year ago #

    Just wanted to say thanks for the code! I was able to make some changes to my favorites page and it was an immense help.

  19. dahlia81
    Member
    Posted 1 year ago #

    Hi,

    Do you think you could post the whole page, not just the excerpts. I think I can go through and take out anything custom easier. I've tried to get your code working and I think I'm missing something basic.

    Excited to get this to work especially the way you have it. I'm on 3.5 and its just not showing up yet. Thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.