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


Flexible Content not displaying data from Author page

  • Hi there!

    I’m using ACF PRO, Version 5.6.5 (I have tried older versions as well).

    So what I’m doing is setting up a ‘Author Addons’ in the Custom Fields.

    Now, I click it and I have the Group Fields I can edit.

    So I need Social Media, I create that as a flexible content.

    I give it a name of ‘Social Media Icons’.

    Then I give the single name of ‘Media Facebook’.

    Show this field group if:
    ‘USER ROLE” is equal to “ALL”.

    I want this to be displayed in the Admin.

    It works! I can put in the information and it works! However, there is one problem. It doesn’t show up in the front-end of the website. It says ‘content not found’.

    I know it works because I then changed the field groupt to display for post page and put contact page or any other page, and it displayed the content.

    It needs ot be unique, many authros will have different info of course.

    But this just doesn’t work. Flexible Content Field doesn’t work on Admin page. Neither does repeater.

    I have installed the WP site many times.

    I even used one default WordPress theme, twenteey fourteen etc… and all I did put in the author page with the felxible content code, and just the plugin with the same field – it didn’t work either.

    I have been on this for more than two weeks, I can’t figure this out.

    I suppose I need to pass in the ID of the author to identify it, but it doesn’t seem anything I do works.

    Here is the code

                        while ( have_posts() ) : the_post();
                        if( have_rows('social_media') ):
                            // loop through the rows of data
                            while ( have_rows('social_media') ) : the_row();
                            // check current row layout
                                if( get_row_layout() == 'social_media_icons' ):
                                echo get_sub_field('media_facebook');       
                        else :
                            // no layouts found
                            echo 'no content';
                        endwhile; // End of the loop.
  • The standard WP loop will not work here, and yes, you need to supply the correct value for post ID. See this 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!

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Flexible Content not displaying data from Author page’ is closed to new replies.