WordPress.org

Ready to get started?Download WordPress

Forums

WP Favorite Posts
Custom post type (21 posts)

  1. maxj
    Member
    Posted 1 year ago #

    Hi, I'm using custom post type to create my posts and the plugin dosn't work. I can see add to favorites button on the post page; I can klick to add it and I get a message that the post is my favorite one but when I go to the page that should show the favorites post list there is nothing to show. I was trying with a regular post and everything is working. How do I do if I want be able safe my custom post as favorites?

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

  2. lifesgood
    Member
    Posted 1 year ago #

    Maxj, this, unfortunately, won't help you, but I am experiencing the same problem.

    However... it definitely used to work on Custom Post Types... I built a whole directory around the idea of users being able to "favorite" directory listings for later reading. So I really need to get it working again!

  3. maxj
    Member
    Posted 1 year ago #

    Lifesgod, I found a different solution: http://codecanyon.net/item/user-bookmarks-for-wordpress/544129
    It is almost perfect but You can not use it if users are not logged in. I hope It can help You.

  4. lifesgood
    Member
    Posted 1 year ago #

    Thanks so much Maxj - I'll check it out. Curious... I've just discovered the plugin no longer also works on pages. Does that happen for you also?

  5. lifesgood
    Member
    Posted 1 year ago #

    I have rolled back to 1.5.6 and it works again...

  6. thatwastaxing
    Member
    Posted 1 year ago #

    Thanks lifesgood!

  7. aronjeney
    Member
    Posted 1 year ago #

    Is this really the only way for custom post types to work? Is there any difference in the code somewhere?

  8. alexsean
    Member
    Posted 1 year ago #

    I made it work with my custom post type by going into wpfp-page-template.php and replacing

    query_posts(array('post__in' => $favorite_post_ids, 'posts_per_page'=> $post_per_page, 'orderby' => 'post__in', 'paged' => $page));
    while ( have_posts() ) : the_post();
       echo "<li><a href='".get_permalink()."' title='". get_the_title() ."'>" . get_the_title() . "</a> ";
       wpfp_remove_favorite_link(get_the_ID());
       echo "</li>";
    endwhile;

    with

    foreach ($favorite_post_ids as $post_id) {
        $p = get_post($post_id);
        echo "<li>";
        echo "<a href='".get_permalink($post_id)."' title='". $p->post_title ."'>" . $p->post_title . "</a> ";
        wpfp_remove_favorite_link($post_id);
        echo "</li>";
    }

    Hope that helps someone.

  9. maxj
    Member
    Posted 1 year ago #

    alexsean I own You!

  10. Tech4Eleven
    Member
    Posted 1 year ago #

    Alexsean, this fixed it for me too! I'm using a custom post type and I could click to favorite but it would never add it to my list page. I could even favorite a post on the post single page and it wouldnt list it. your code fixd both my issues!!!!

    thank you so much.

  11. lifesgood
    Member
    Posted 1 year ago #

    Thanks Alex - this worked for me too!

  12. Tech4Eleven
    Member
    Posted 1 year ago #

    @alexsean, are you using v1.5.8 with this code? I'm using v1.5.6 with this code and it works but wondering if I can upgrade the latest version. Do your posts clear out of the favorites page when clicked? Mine dont- i have to manually refresh the page to get them to clear out.

  13. alexsean
    Member
    Posted 1 year ago #

    We have v 1.5.8 installed. Clicking the remove song or the clear list links clears the songs and refreshes without the songs displayed.

  14. Tech4Eleven
    Member
    Posted 1 year ago #

    ok thanks. my page template's ajax still doesnt work even with 1.5.8 but i'll keep looking.

  15. websta
    Member
    Posted 1 year ago #

    alexsean, your fix worked perfectly on custom post types.

    <Does the "88 miles per hour" dance>

    Thank you!

  16. Flick
    Member
    Posted 1 year ago #

    I just wrote my own page template which seems to work well, so through I'd share... You can use the function to get the favourite ids out and write your own loop query...

    if ( function_exists('wpfp_get_users_favorites') ) $fp_ids = wpfp_get_users_favorites(); to get the IDs and writing your own query...

    Here's an example:

    if ( function_exists('wpfp_get_users_favorites') ) $fp_ids = wpfp_get_users_favorites();
    
    query_posts(array('post_type' => 'your-post-type', 'post__in' => $fp_ids, 'orderby' => 'post__in'));
    if ( have_posts() ) :
    	while ( have_posts() ) : the_post(); ?>
    	<div class="post-item"><a href="<?php the_permalink(); ?>">
    	<?php the_post_thumbnail(); ?><?php the_title(); ?></a>
    	<?php wpfp_remove_favorite_link( get_the_ID() ); ?>
    	</div>
    <?php endwhile; // end of the loop.

    This way you can display the list of favourites anyway you like...

  17. triggeru571
    Member
    Posted 10 months ago #

    Hi Flick, great stuff. Could you please tell me, does your code above go into functions.php or does it go in one of the plugins files?

  18. Flick
    Member
    Posted 10 months ago #

    Hi triggeru571,

    I put this code into a Template file directly... I created a template file in my Theme for the favourties page. You could put the code in your functions file by putting the relevant code inside a few hooks though.

  19. christelle017
    Member
    Posted 10 months ago #

    It still dos not work for me even if I change the code as Alexsean explained :(
    Somebody has another solution ?

  20. Adam Taylor
    Member
    Posted 8 months ago #

    Thank you alexsean. The code replacement in wpfp-page-template.php worked perfectly for me. Been looking all day for a solution :)

  21. Ata JBZ
    Member
    Posted 6 months ago #

    Hi guys;

    the above code inside the wpfp-page-template.php outputs the favs of the current user, with post-type issues that you probably solved.

    I'm trying to query most favorited of custom type 'idea' on archive-ibest.php .

    here's the code of archive-ibest.php :

    <?php
        $custom_query = new WP_Query(array(
            'post_type' => 'idea',
            'meta_key' => 'wpfp_favorites',
            'orderby' => 'meta_value',
    
    		));
    
    ?>
    <?php if (have_posts()): ?>
    <?php while ($custom_query->have_posts()) : $custom_query->the_post(); ?>
    
    			<!-- Content Template -->
                                                    <?php include (TEMPLATEPATH . '/CONTENTS/idea.php'); ?>
    			<!-- Content Template -->
    
    						<?php endwhile; ?>
    						<?php wp_reset_postdata(); ?>
    						<?php endif; ?>

    just nothing appears as results.

    I would be grateful for any help. I've also created a thread for this but nothing yet. here it goes :

    wordpress.org/support/topic/querying-top-posts-of-a-custom-post-type?replies=3

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.