• Resolved sgtan2264

    (@sgtan2264)


    How can we use field Key to display Author content in other section?

    We saw there is a field key and would like to use it to display fields such as country and gender. However, we used it under author meta or user meta, it doesnt work, may we know how we can use it?

    eg uwp_country

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    Can you show the shortcode or code which is not working for you? You can use user meta shortcode by passing user ID and custom field key and how it should display. For example [uwp_user_meta user_id=’1′ key=’uwp_country’ show=”]. If you don’t use the user_id parameter then it will take the currently logged-in user ID and if the shortcode is displayed on the profile page then it will take the displayed user ID.

    Regards,
    Patrik

    Thread Starter sgtan2264

    (@sgtan2264)

    Not sure if this is appropriate as it is an aduit website.
    https://fantoric.com/pussluver/fate-or-destiny-the-beginning-part-11/

    we are using beaver builder, we want to display the country under our profile.

    We tried adding user meta or author meta it doesnt work. we want to add the generic field for the author not specific. we dont need user id.

    • This reply was modified 3 years, 3 months ago by sgtan2264.
    Plugin Contributor Paolo

    (@paoltaia)

    Hi,

    beaver builder, as far as I know, doesn’t have that kind of dynamic content capability (it would need to be able to fetch the author id of the post to be used in our shortcode).

    We added a task to add the option to use our shortcode outside of the profile page and to get the ID post author ID automatically on blog posts.

    For now, please try this function (you can add it to functions.php of your child theme or through a code snippet):

    function _my_get_author_country( $atts ) {
        if ( is_single() && $author_id = get_the_author_meta( 'ID' ) ){
        	 return do_shortcode("[uwp_user_meta user_id='$author_id' key='uwp_country']");
        }
    }
    
    add_shortcode( 'my_get_author_country', '_my_get_author_country' );

    Then use the shortcode [my_get_author_country] where you want to output the country. I think with Beaver Builder you need to use a text area widget for that.

    We haven’t tested the function, so it could need some tweaking, let us know how it goes.

    Thanks,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How can we use field Key to display Author content in other section?’ is closed to new replies.