WordPress.org

Ready to get started?Download WordPress

Forums

myCRED
[resolved] get automaticly post author ID (8 posts)

  1. fcpro
    Member
    Posted 11 months ago #

    Hi,
    How can we get automaticly the "post author ID" using this shortcode ?

    [mycred_post_view user_id="GET USER POST" amount="-0.15" limit="1" log="visit IP" ref="IP_Visitor" ]

    Thank you in advance.

    https://wordpress.org/plugins/mycred/

  2. Gabriel
    Member
    Plugin Author

    Posted 11 months ago #

    Hi.

    Depending on how your mycred_post_view shortcode is setup, it would be easiest to get the post ID in that shortcode.

    For example adding the following to the code that renders the shortcode:

    global $post;
    $post_id = $post->ID;
  3. fcpro
    Member
    Posted 11 months ago #

    <?php
    echo do_shortcode( '[mycred_post_view user_id="3" amount="-0.20" limit="1" log="visite IP unique" ref="IP Visitor" ]' );
    ?>

    Coding is directly in the file template.

    Is that what you mean by set up ?

  4. Gabriel
    Member
    Plugin Author

    Posted 11 months ago #

    You can use:

    <?php
    global $post;
    echo do_shortcode( '[mycred_post_view user_id="' . $post->ID . '" amount="-0.20" limit="1" log="visite IP unique" ref="IP Visitor" ]' );
    ?>

    As long as this is done inside the loop.

  5. fcpro
    Member
    Posted 11 months ago #

    Yes I got it to work without the ' before and after: . $post->ID .
    Like this: user_id=" . $post->ID . "

    Thank you :)

  6. Gabriel
    Member
    Plugin Author

    Posted 11 months ago #

    Excellent news! Thank you for keeping me updated!

  7. fcpro
    Member
    Posted 11 months ago #

    Hi,
    For some reasons I can't get the shorcode above (mycred_post_view user post->ID) to work anymore on an other (different) website. It's very strange !?

    I'm trying to insert php shortcode into custom post type (single biz listing)

    So I'm trying to remember: is there any thing else I needed to do (filter in theme function) or active hooks or addons !?

    Can you help me

  8. fcpro
    Member
    Posted 11 months ago #

    Got it to work now.
    The solution was adding filter code into theme function.

    Sorry

Reply

You must log in to post.

About this Plugin

About this Topic