Help: Custom User playlist from favorited posts

My client creates educational video posts. I’m trying to combine a WP Favorites plugin (this one) and a CPT (ToolsetTypes) so users have access to a Favorites page of just the videos without their posts.

I’ve added a CPT that requires them to add the URL of the video they’re embedding. I am trying to create a page for individual users that says “if favorited, take the URL from the post’s CPT field and embed onto this page” creating a page of just embedded videos the logged in user has Favorited.

So far nothing I’ve come up with has successfully created the outcome I desire, and at this point, I think I’ve just got a mess on my hands (I’m not as proficient as I wish I was in PHP).

Here’s the first part:

function favoritesPlaylist($atts) {
$a = shortcode_atts( array(
‘id’ => ”,
), $atts );

$a[‘id’] = intval($a[‘id’]);
if ($a[‘id’] <= 0) { return “”; }
$return = ”;
ob_start();
$args = array(
‘post_type’=> ‘posts’,
‘post_status’ => ‘publish’,
‘post__in’ => array($a[‘id’]),
‘posts_per_page’ => 1,
);

$custom_query = new WP_Query( $args );
if($custom_query->have_posts() ):
while ( $custom_query->have_posts() ):
$custom_query->the_post();
$favoriteId = get_the_ID();
$favoriteUrl = types_render_field(‘video-url’, array(‘output’=>’raw’));
$favoriteGrade = types_render_field(‘age-group’, array(‘output’=>’raw’));
?>

What I’m not sure about is how to grab the favorited parameter and incorporate it into the function. The site provides a ton of resources for referencing the favorited videos, but I’m not sure how to incorporate them.

My other question is about delivery – as you can see above, my initial plan was to create a shortcode for the page, but would it be more efficient to just create a template?

Any assistance here would be amazing. Thanks!

Read more here:: Help: Custom User playlist from favorited posts

Leave a Reply

Your email address will not be published. Required fields are marked *