• Resolved johaan89

    (@johaan89)


    Great plug-in love it, it’s great, however would it be possible to get it to work with a plug-in such as this one https://favoriteposts.com/ to have it load user favorites? been looking over the docs and having found anything related to this sort of thing. There probably is but I might have missed it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter johaan89

    (@johaan89)

    Well… nevermind I was able to figure it out. Here’s the code I used to have ajax more load a list of user favorited posts

    <?php 
    
    $favorites = get_user_favorites();
    if ( $favorites ) : // This is important: if an empty array is passed into the WP_Query parameters, all posts will be returned
    $favorites_query = new WP_Query(array(
    	'post_type' => array('post'),
    	'ignore_sticky_posts' => true,
    ));
    while ( $favorites_query->have_posts() ) : $favorites_query->the_post();
    	$favorites[] = $post->ID; 
    endwhile;  ?>
    
    <?php 
    endif; wp_reset_postdata();
    
     ?>
    
    <?php
    
       
    
    echo do_shortcode('[ajax_load_more post__in="'. implode(',',  $favorites) .'" orderby="post__in"]'); 
    ?>

    unless there’s a better way of doing this?

    • This reply was modified 7 years, 6 months ago by johaan89.
    • This reply was modified 7 years, 6 months ago by johaan89.
    • This reply was modified 7 years, 6 months ago by johaan89.
    Plugin Author Darren Cooney

    (@dcooney)

    Hey @johaan89,
    Nice one. This is exactly how I was going to suggest.

    Thanks for sharing the code.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Would it be possible to get this to work with Favorites?’ is closed to new replies.