Home Forums Add-ons Flexible Content Field Flexible Content not displaying data from Author page Reply To: Flexible Content not displaying data from Author page

  • Amazing!

    I’ll write for those who are new, like my self. I could have solved this with more experience.

    I hope you don’t mind and it helps others. Correct me if I’m wrong but:

    There are many Authors, if you take a field of one author, then it won’t know what field to take. So to diference them, we need to identify it.

    We can do this by getting their id. But what now?

    Well, in WordPress ( I believe ), if we look at this code

    <?php if( have_rows('repeater', 'user_1') ): ?>

    It says, if it has rows in repeater, withing the user of ID 1, be it yourself, than do whatever.

    What if we want it to be dynamic?

    As on the page says
    “The $post_id parameter needed is a string containing the word ‘user_’ and the user’s ID in the format; “user_{$user_id}””

    Which means:

    You need to get the user ID

    $author_id = get_the_author_meta('ID');

    And since the ID is there -> ‘user_1’
    We need to replace the number with the user ID.

    Since the get_the_authro_meta get’s the id, we can concatinate that

    if( have_rows('social_media','user_'. $author_id) ):

    Hope it helps for those who find this!