• Resolved impulsionmedia

    (@impulsionmedia)


    Hi,

    Thanks a lot for the plugin, exactly what i needed. Simple and light.

    just wondering if it’s possible to customize the list output and use it as a template in our theme. Right now i am actually customizing it in the plugin folder which i Think is not that great for eventual updates!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Takashi Matsuyama

    (@takashimatsuyama)

    Hello @impulsionmedia,

    Thank you for your review.

    I’ve been trying to figure out a way to make the list output more flexible and customizable.

    For example, in a future update, I’ll try to add a shortcode that returns only the saved post IDs.

    I’d like to update it so that it only gets the favorite post IDs and the theme can design the list more freely.

    Thread Starter impulsionmedia

    (@impulsionmedia)

    Just saw the update… I will try it out shortly… thanks

    Plugin Author Takashi Matsuyama

    (@takashimatsuyama)

    Thanks for your comment.
    Please, try it.

    This is a simple sample code to write in “your-theme/functions.php”.

    function ccc_my_favorite_list_custom_template( $my_favorite_post_id=false ) {
      $args= array(
        'post_type' => 'any',
        'post__in' => $my_favorite_post_id,
        'orderby' => 'post__in',
        'posts_per_page' => -1,
      );
      $the_query = new WP_Query($args);
      if( $the_query->have_posts() ) {
    ?>
    <p id="ccc-favorite-count"><span class="number"><?php echo $the_query->post_count; ?></span></p>
    <div data-ccc_favorite-delete_all=true><a href="#" class="ccc-favorite-post-delete-button">All Delete</a></div>
    <?php
        while( $the_query->have_posts() ) {
          $the_query->the_post();
    ?>
    <div class="list-ccc_favorite">
      <p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
      <div class="ccc-favorite-post-toggle"><a href="#" class="ccc-favorite-post-toggle-button" data-post_id-ccc_favorite="<?php echo $the_query->post->ID; ?>"></a></div>
    </div>
    <?php
        } //endwhile
      } //endif
    } // endfunction

    shortcode: [ccc_my_favorite_list_custom_template style="none"]
    style="none" excludes the default CSS for the list.

    Thread Starter impulsionmedia

    (@impulsionmedia)

    Hi, i applied your code to my function page with my layout and used your suggested shortcode and everything works. Now i just need to customize it in my OWN function page which is fantastic. Greatly appreciated.

    I added a “else” statement if there are no favorites to add a message. It works when you load the list page if they are no favorites already. But if i am in the list page and i remove favorites until there are 0, it does not show the message. it does show the “favorites : 0” count but not my “else” message. If i hit the browser refresh button it appears. It’s not a bid deal, just wanted to let you know. probably related to ajax or something.

    Thanks again

    Plugin Author Takashi Matsuyama

    (@takashimatsuyama)

    Hello @impulsionmedia, thank you for your review.

    It is as you say.
    When deleting a favorite on a list page, it is not rewritten with Ajax.

    Because when the delete button is clicked, it is hide just “display:none” of CSS and the counter is rewritten with JS.
    However, when you access this page again, it is loaded from the DB with Ajax, so it displays a 0 for message in PHP.

    I’ll think about a better method as a future task.
    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Template’ is closed to new replies.