• Hi,

    Wonderfull plugin!

    I am wondering if it would be possible to add a author=”current_post_author” argument that is different from the existing author=”current” argument.

    For example in a post, I have added the following shortcode in a sidebar widget ->
    [display-posts post_type=”job_listing” posts_per_page=”5″]

    If I add author=”current”
    “current” -> displays the posts of the logged in user
    If I add author_id=”2″
    “2” -> displays the posts of the user_id #2

    But I can’t figure out how to display additional posts from the post’s author.

    Post ABC added par Alex (author_id=”321″).
    In post ABC, I would like to display:
    – Post added by Alex – OK
    – A list of 5 other posts added by Alex – NOT OK, I am stuck

    Here a screenshot = https://singapore-lah.com/Capture.PNG

    Thank you so much if you could point me in the right direction!

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

Viewing 1 replies (of 1 total)
  • Thread Starter Prospekto

    (@prospekto)

    Hi,

    I finally managed to find a way to achieve what I needed. But WP coders will probably laugh about it! I am sure there is a better way I guess.

    I have added the following in function.php to place the shortcode [author_posts] in a widget.

    function author_posts_shortcode(){
        global $post;
        $post_id = $post->ID;
        $author_name = get_the_author($post_id);
        $author = get_the_author_meta( 'ID' );
        $post_author = "[display-posts wrapper_class=\"author-list\" post_type=\"job_listing\" author_id=\"$author\" posts_per_page=\"5\"]";
    	echo '<h2 class="widget_sidebar_title">Posted by</h2>';
    	echo '<p class="author">';
    	echo $author_name;
    	echo '</p>';
    	echo do_shortcode( $post_author );
    }
    add_shortcode('author_posts','author_posts_shortcode');
Viewing 1 replies (of 1 total)
  • The topic ‘author=”current_post_author”’ is closed to new replies.