Forum Replies Created

  • Hi,

    I’m not sure why this is marked as solved, when it’s not.

    However, I’m creating a website that’s 100% modular, done with Flexible Content.

    I have Pages such as:

    Home, About, Services, Blog, Portfolio, Contact
    All of those pages styled using Flexible Content, these are PAGES.

    I have created a custom field for Services and Portfolio, and I used WP Query to display each individal item. These are CUSTOM fields. Show this field group if post type to Services. Not a page.

    So when you click it, what happens you go to single-[custom-post-type].php, however I just have single.php to keep it dynamic, which works.

    The problem lays that when I have showed the flexible content page templates in the Services or Portfolio, and I add few items, I need go to every single item and set the layout.

    How can I do so the layout stays all the same in Service or Portfolio custom field?

    We need to be able to use ACF Flexible content to modify the look for single-services.php page, or single-portfolio.php page, and all of them need to reflect to be identical.

    So if I set a certain layout on one service item, it should be like that on all service items. Same with portfolio.

    Here I have the code, but I don’t think it matters –

  • Hi allisonplus,

    Yes, absolutelly.

    I just want to point out that I’m using ACF Flexible Content as my layout, with the functionality of the ‘Add Row’, so it’s essential to ahve the visual UI on the admin dashboard, like I do have the UI for each page.

    Said that, there is no possibility for me to create a different template by just creating a single.php or single-projects.php, since I can’t ‘Add row’ with them, so all of the single-project.php will have the same header, footer and style, but it needs to be done with Flexible Content – I know it’s possible because people have done it.

  • 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)