How to create post favorite function without plugins

Question

I’m developing a lesson plan plugin … and within this lesson plans you will have the option to favorite which plans users like, I’m listing the registered plans this is very easy using as a shortcode like this below, but I’ve already looked for it until right here how to do it without using a plugin, but always ending up returned to install …. if you can help with examples or content it would help a lot, and I’m sorry for the bad writing in Englishenter image description here

Here is the code where I list the lesson plans

 function lesson_plans(){

    $cale_plan_post = [
        'post_type'      => 'cale-plan',
        'post_status'    => 'publish',
       
    ];
    
   $cale_plan_posts  = new WP_Query( $cale_plan_post);
    while (  $cale_plan_posts->have_posts() ) :  
        $cale_plan_posts->the_post(); 
        echo'<div>
                <div class="">
                    <h2>'; echo the_title().'</h2>';
                    echo the_content().'
                    <a href="https://wordpress.stackexchange.com/questions/407633/; echo the_permalink ().">zz</a>
                </div>
                
                <a  data-post-id="';echo $cale_plan_posts->post->ID. '">♥ Add to favorites</a>
            </div>';
          
       
    endwhile;
    wp_reset_postdata();
}

if ( class_exists( 'Cale_discourse' ) ) {
    register_activation_hook( __FILE__, [ 'Cale_discourse', 'activate' ] );
    register_deactivation_hook( __FILE__, [ 'Cale_discourse', 'deactivate' ] );
    register_uninstall_hook( __FILE__, [ 'Cale_discourse', 'uninstall' ] );
    add_shortcode( 'list_plans' ,'lesson_plans');
  
    $cale_discourse = new GlobalCale_discourse();     
    
}

0
fuxia 5 months 2022-07-13T16:12:14-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse