• Resolved Darren Cooney

    (@dcooney)


    Hello,
    Love the plugin, great job.

    I have an issue where the plugin is not rendering in content fetched via Ajax using wp-admin/admin-ajax.php

    My code in the template is as follows:

    `
    $postid = get_the_ID();
    $content = do_shortcode(get_post_field( ‘post_content’, $postid ));
    $content = apply_filters(‘the_content’, $content);
    echo $content;
    `

    Shortcode, content and images are returned without issue, except the share icons are not.

    It seems like the_content filter may not be running. Do you know if the Shared Count classes are being loaded is_admin()?

    Thanks in advance ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Bill Erickson

    (@billerickson)

    Thanks for the message.

    The “theme locations” only run in the singular context (ex: is_singular( ‘post’ ) ). An AJAX request will return false for is_singular( ‘post’ ) and therefore they won’t be added.

    But you can use the built-in methods to manually add it yourself. Ex:

    if( function_exists( ‘shared_counts’ ) ) {
    $content .= shared_counts()->front->display( $location = ‘my-location’, $echo = false);
    }

    Thread Starter Darren Cooney

    (@dcooney)

    Thank you @billerickson, this works. Not the most ideal solution for the users of my plugin, but I can at least provide a solution for them.

    Appreciate it!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Not working in admin-ajax.php calls’ is closed to new replies.