• Resolved adityajejurkar

    (@adityajejurkar)


    Hello,
    Thanks for the wonderful plugin. This is exactly what I need but how can I add this favorite button in post listing and single post category. Just like the share button, we have in every post I want the same favorite button to be shown in the post category listing and in a single post.
    Thanks

    The page I need help with: [log in to see the link]

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

    (@takashimatsuyama)

    Hello, @adityajejurkar
    Thank you for your rating and your question.

    You can add them with this shortcode.

    shortcode: [ccc_my_favorite_select_button post_id="your post ID"]

    If you want to put it directly to your theme’s PHP file, try writing code like this.

    <?php
        if( shortcode_exists( 'ccc_my_favorite_select_button' ) ) {
            echo do_shortcode('[ccc_my_favorite_select_button]');
        }
    ?>

    Please add this in the loop of WP_Query or in single.php.

    Please try it in a test environment first.

    Thanks

    Thread Starter adityajejurkar

    (@adityajejurkar)

    Hello Takashi,
    Thanks for the above quick reply. Is there any way I can add the code in function.php where it can directly append it to all posts?
    Thanks

    Plugin Author Takashi Matsuyama

    (@takashimatsuyama)

    Hello, @adityajejurkar

    Sorry. I haven’t tried that, but maybe you can do it by writing “add_filter()” to add the shortcode.

    add_filter( 'the_content', 'function_add_shortcode' );
    function_add_shortcode() { …… }

    Perhaps like this.

    Thanks

    Thread Starter adityajejurkar

    (@adityajejurkar)

    Hello @takashimatsuyama ,
    No worries got the solutions.
    Thanks for the plugin.

    Thread Starter adityajejurkar

    (@adityajejurkar)

    Hello @takashimatsuyama,
    I’d check the previous support ticket where how we can change the icon from heart to any other option. It didn’t work for me. What I want is a bookmark icon rather than the heart icon. Tried overriding the CSS as well still no success. Hope you have any solution to this.
    Thanks

    Plugin Author Takashi Matsuyama

    (@takashimatsuyama)

    Hello, @adityajejurkar

    Would the following topics be helpful?
    https://www.ads-software.com/support/topic/svg-icon-2/

    Thanks

    Thread Starter adityajejurkar

    (@adityajejurkar)

    Hello @takashimatsuyama ,
    Yes I tried no success!

    Plugin Author Takashi Matsuyama

    (@takashimatsuyama)

    Hello, @adityajejurkar
    Can you put some of your CSS code in this topic?

    Thread Starter adityajejurkar

    (@adityajejurkar)

    Hello @takashimatsuyama,
    Below is the CSS which I’ve added in the customise:
    .ccc-favorite-post-toggle > a::before{
    content: ” “;
    background-image: url(‘https://speutarl.sirv.com/icons8-bookmark.svg&#8217;);
    background-repeat: no-repeat;
    display: inline-block;
    vertical-align: middle;
    height: 20px;
    width: 20px;`
    }

    The icon is not visible after adding the css:
    Screenshot: https://prnt.sc/xQqkxVjKcaaj

    If you want you can try overriding on this page as well:
    https://leadib.learningbus.in/organic-chemistry/

    Thanks

    Plugin Author Takashi Matsuyama

    (@takashimatsuyama)

    Hello, @adityajejurkar

    How about this?

    .ccc-favorite-post-toggle > a::before {
        content: " ";
        background-image: url('https://speutarl.sirv.com/icons8-bookmark.svg');
        background-repeat: no-repeat;
        vertical-align: top;
        height: 20px;
        width: 20px;
    
        background-size: 100%; /* add */
        background-position: center center; /* add */
        display: inline-block; /* add */
    }

    Then you can easily override it with your theme’s CSS by writing the following.

    .your_class_or_id .ccc-favorite-post-toggle > a::before {
       …
    }

    Thanks

    Thread Starter adityajejurkar

    (@adityajejurkar)

    Hello @takashimatsuyama,
    Thanks for the reply, I’ve added the CSS, but this is how it looks when I toggle click on it. The ::before icon is appearing but when I click on it the heart filled icon appears. Here it should show the bookmark icon filled rather than the heart.
    Screenshot: https://prnt.sc/oSCzDvdn4I9f
    Please Check

    Plugin Author Takashi Matsuyama

    (@takashimatsuyama)

    Hello, @adityajejurkar

    You can do it by changing the following code.
    .ccc-favorite-post-toggle > a.save::before { … }

    It adds “.save” when clicked.

    You can check it in the inspector of your browser (DevTools).
    Icons and styles can be adjusted with standard CSS.

    Thanks

    Thread Starter adityajejurkar

    (@adityajejurkar)

    Hey @takashimatsuyama,
    Thanks for the above option. It worked. One last thing, I want the users to log in first and then save the post. Currently, they can save with or without login. Any way I can restrict them from saving without logging in.
    Thanks

    Plugin Author Takashi Matsuyama

    (@takashimatsuyama)

    Hello, @adityajejurkar
    You’re welcome.
    I’m glad it worked out.

    This plugin itself does not prompt for login.
    However, it can be displayed only to logged-in users.
    Please use the standard WordPress functions.

    For example :

    <?php
    if ( is_user_logged_in() ) {
        if( shortcode_exists( 'ccc_my_favorite_select_button' ) ) {
            echo do_shortcode('[ccc_my_favorite_select_button]');
        }
    }
    ?>
    

    Thanks

    Thread Starter adityajejurkar

    (@adityajejurkar)

    Hello @takashimatsuyama ,
    The above solution sounds fair to me as well. But additionally, I would like to tell you one thing. Keep up the good work, you’re the best.
    Thanks a bunch

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Adding favorite post button on post category list and single post’ is closed to new replies.