• Resolved Kimkia

    (@kimkia)


    Love this plugin and it works wonderfully on individual post pages, but I’d also like to get it to work above my category pages as well.

    I’m using Genesis News theme. I tried implementing
    ‘<?php do_action(‘crafty-social-share-buttons’); ?>’ in various places using the Genesis Simple Hooks plugin. I can get the Share buttons to display on Category pages but they all point to the url of whatever post is at the top of the list. If I try to place the Share buttons at the bottom, they pick up the url of the last post listed.

    I’d love to get a workaround for this, so that the buttons will share the url for the category and be displayed near the top of the page.

    Can you help me please?

    https://wordpress.org/plugins/crafty-social-buttons/

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Sarah

    (@shen045)

    At the moment, the plugin is really designed to work inside the loop, that’s how it gets the URL to share for each post. It should be possible to extend it to work with category pages as well. I’ll try and have a look at this in the next few days.

    Thread Starter Kimkia

    (@kimkia)

    Thank you. It would be lovely if you can work this out. Appreciate your help.

    Plugin Author Sarah

    (@shen045)

    I have added a new action hook in the latest version (1.3.0) that will let you to share any page:

    <?php do_action('crafty-social-share-page-buttons'); ?>

    If you add this to your category page template (before or after the loop), it should share the category page itself.

    Let me know if this meets your needs.

    Cheers,
    Sarah

    Thread Starter Kimkia

    (@kimkia)

    Sarah,
    You are amazing. There are many social sharing buttons out there that haven’t been able to sort this out.
    Because I already had this working on my post pages, the new changes resulted in two versions appearing, so I had to adjust my settings to Shares Each Post on Category Pages and it seems to be working perfectly. If this works out, and I can share your beautiful buttons on categories and posts, then I will definitely be searching your site for a donate button.
    My site (http://www.allfreecrafts.com/) has been around since 2002, and I’ve recently been moving each static page and category over to a wordpress installation. HUGE undertaking. To see the new version in action: http://www.allfreecrafts.com/gardening/perennials/
    You’ve just provided a bonus that makes all the work much easier, more worthwhile, and much easier to understand.
    Thank you so much.

    Hi shen, I tried adding the code to my category page.

    The problem I’m facing is that even after adding the code within the loop, the buttons share the link of category page and not the posts in those categories.

    I want my buttons to share the links of the posts in those categories. Can you please have a look??

    Thanks for the awesome plugin. Works really great… 🙂

    Thread Starter Kimkia

    (@kimkia)

    That’s interesting, kakashihatake2, because what you’re getting is exactly what I want. On the category archive (index pages) I definitely do NOT want sharing buttons appearing above each of the post beginnings that are shown on this category page.

    Perhaps you are displaying the entire posts, rather than excerpts or character-limited descriptions of the posts like I do.

    It’s a bit of conundrum.

    At the moment, I’ve removed all Crafty Social Buttons because I’ve got significant (and unacceptable to Google) page load issues so I’m trying to scale things down. Hopefully, I can reactivate the plugin when the page load times come down and we’ll see what happens.

    @kimkia Particularly, I want my users to share the posts from there only.

    There can be 2 ways the plugin can work in the Category Pages.
    1. If the social buttons are called outside the loop, it should use the address of that page where you are on
    2. f the social buttons are called inside the loop, it should use the address of the posts from the loop(in that category)

    So, I suggest shen to use the ‘get_the_ID()’ function and check if there is a post in it. If there is a post present in it, then the link to be shared should be what comes from ‘the_permalink()’ function. Right shen?

    Plugin Author Sarah

    (@shen045)

    There are two different action hooks, one that works with the loop and one which doesn’t.

    When you want the sharing buttons to be output for each post in the loop, then this action hook should do the trick:
    <?php do_action('crafty-social-share-buttons'); ?>
    But the easier way would be to just use the plugin options. There is an option there to automatically output it on each post on a category page (or archive page), without needing to add in action hooks manually.

    If you need to share a page that doesn’t have a loop, or you want to share the page itself and not the items in the loop on that page, then you’d want to use this one:
    <?php do_action('crafty-social-share-page-buttons'); ?>

    It takes no notice of the loop, it simply figures out the URL of the page it is on, and shares that. So this would be the one to use if you wanted to share the URL of the category page itself, rather than the items on the page.

    Ok, thanks for the reply shen….

    I think that option to automatically output the buttons on each post on a category page (or archive page) is not working. I removed <?php do_action(‘crafty-social-share-page-buttons’); ?> , and then I could not see any buttons…

    I think you should re-check at your end if its working properly at your end.

    I will start using the other action hook for the moment. Thanks for letting me know about it. Also, I suggest you add a like button it as well. I mean, sometimes users don’t like to share, but they can like that page instead.

    I hope I’ll see that in the future updates… 🙂

    Thanks again… Awesome plugin… 🙂

    Plugin Author Sarah

    (@shen045)

    Do you have the full content displaying on the category page or just an excerpt? Different themes do it different ways, but it if is an excerpt only, the buttons won’t show up as they are only output with the full content.

    Here’s an example of the buttons being output on each post on a category page (http://sarah.geek.nz/blog/category/india/). This is just using the options in the settings page, not using one of the action hooks.

    Do you have any caching plugins enabled?

    You are right… its the excerpts…

    Guess I’d have to use the code only that way then… 🙂

    Thanks again… 🙂

    Thread Starter Kimkia

    (@kimkia)

    I’ve replaced my buttons and am now using <?php do_action(‘crafty-social-share-page-buttons’); ?> via the Genesis Simple Edits plugin, and it’s working nicely. Appearing just below the main menu bar and breadcrumb links. And, fingers crossed, it seems to be working ok with my cache and speed booster plugins too.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Share Buttons for Categories’ is closed to new replies.