Viewing 9 replies - 1 through 9 (of 9 total)
  • Hey!

    replace this line in the file wpfp-page-template:

    query_posts(array('post__in' => $favorite_post_ids, 'posts_per_page'=> $post_per_page, 'orderby' => 'post__in', 'paged' => $page));

    with:

    query_posts(array('post__in' => $favorite_post_ids,'post_type' => 'any', 'posts_per_page'=> $post_per_page, 'orderby' => 'post__in', 'paged' => $page));

    [s]

    Thread Starter jeroenverburgt

    (@jeroenverburgt)

    Thanks! It didn’t work, but got me to think: I replaced the post_type Any with the actual post type (a foreign post type) where I need it, and it works like a charm!

    Thanks gilbarbara,

    that worked for me!

    Hey, the solution above
    query_posts(array('post__in' => $favorite_post_ids,'post_type' => 'any', 'posts_per_page'=> $post_per_page, 'orderby' => 'post__in', 'paged' => $page));
    worked well when I replaced post_trype any with the actual post type. The thing for me is that I have 4 differenet custom post types. Any idea how I can get all 4 working with this? The slugs are:

    directory, restaurant-cafe, events, travel-tip-review

    Thanks

    Hi triggeru,

    not a big expert but I guess you have to do something like this:

    query_posts(array('post__in' => $favorite_post_ids,'post_type' => array('directory','restaurant-cafe','events','travel-tip-review'), 'posts_per_page'=> $post_per_page, 'orderby' => 'post__in', 'paged' => $page));

    In the current version of this plugin(Version 1.6.0 with WordPress 3.8), I was able to figure out how to add a custom post type as follows…

    In wpfp-page-template.php, change this:

    // custom post type support can easily be added with a line of code like below.
    //$qry['post_type'] = array('post','page');
    query_posts($qry);

    To this:

    // custom post type support can easily be added with a line of code like below.
    $qry['post_type'] = array('post','page','YouCustomPostType');
    query_posts($qry);

    Where, ‘YouCustomPostType’ is the non-plural form of your custom post type. You can add on as many custom post types as you need. Hope this helps!

    Anyone know how to add the custom post types in the widget?

    Here’s how I fixed it, similar to above:

    Replace:
    $qry = array('post__in' => $favorite_post_ids, 'posts_per_page'=> $post_per_page, 'orderby' => 'post__in', 'paged' => $page);

    With:
    $qry = array('post__in' => $favorite_post_ids,'post_type' => 'any', 'posts_per_page'=> $post_per_page, 'orderby' => 'post__in', 'paged' => $page);

    Ced

    (@cedriccharles)

    Or, in order to not edit the core plugin files, you can create your own page template and put this code where you want the list to appear (it’s the content of wpfp-page-template.php, plus global variables) :

    <?php
      				  global $favorite_post_ids;
                if ( !empty($user) ) {
                    if ( wpfp_is_user_favlist_public($user) )
                        $favorite_post_ids = wpfp_get_users_favorites($user);
    
                } else {
                    $favorite_post_ids = wpfp_get_users_favorites();
                }
                $wpfp_before = "";
                echo "<div class='wpfp-span'>";
                if (!empty($user)) {
                    if (wpfp_is_user_favlist_public($user)) {
                        $wpfp_before = "$user's Favorite Posts.";
                    } else {
                        $wpfp_before = "$user's list is not public.";
                    }
                }
    
                if ($wpfp_before):
                    echo '<div class="wpfp-page-before">'.$wpfp_before.'</div>';
                endif;
    
                echo "<ul>";
                if ($favorite_post_ids) {
            		$favorite_post_ids = array_reverse($favorite_post_ids);
                    $post_per_page = wpfp_get_option("post_per_page");
                    $page = intval(get_query_var('paged'));
    
                    $qry = array('post__in' => $favorite_post_ids, 'posts_per_page'=> $post_per_page, 'orderby' => 'post__in', 'paged' => $page);
                    // custom post type support can easily be added with a line of code like below.
                    $qry['post_type'] = array('post','page');
                    query_posts($qry);
    
                    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;
    
                    echo '<div class="navigation">';
                        if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?>
                        <div class="alignleft"><?php next_posts_link( __( '← Previous Entries', 'buddypress' ) ) ?></div>
                        <div class="alignright"><?php previous_posts_link( __( 'Next Entries →', 'buddypress' ) ) ?></div>
                        <?php }
                    echo '</div>';
    
                    wp_reset_query();
                } else {
                    $wpfp_options = wpfp_get_options();
                    echo "<li>";
                    echo $wpfp_options['favorites_empty'];
                    echo "</li>";
                }
                echo "</ul>";
    
                echo '<p>'.wpfp_clear_list_link().'</p>';
                echo "</div>";
                wpfp_cookie_warning(); ?>

    And simply change the $qry['post_type'] array to add your custom post type ??
    Hope that works and that helps ?? !

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Favorite in custom post type not working’ is closed to new replies.