Support

Account

Home Forums General Issues Use the same content on multiple pages

Solved

Use the same content on multiple pages

  • I would like to display the content added into a set of fields on multiple pages. On a post page, the backend user enters the data into the fields, which should display on that post but also populate on a page. How can I add that content in multiple places without entering it twice in the CMS? Thanks!

  • If you are not using the block editor there is only one way that I would do this and that is to use ACF Pro and create an options page and that is where it would be entered.

    There are topics here about getting blocks that use ACF from other posts. I do not use the block editor and I cannot tell you how to do this. Searching for this should turn up some recent results.

    If you are not using the block editor the you can either use an options page as above or you can supply the post ID to get the values from the other post if you know the post ID

    
    get_field('your_field_name', $post_id);
    

    see https://www.advancedcustomfields.com/resources/how-to-get-values-from-another-post/

  • Thanks so much, John! I don’t need to use the block editor, so the get_field you showed and the article you linked, work well. I did search extensively before posting, but I guess I didn’t use the right keywords. Thanks again!

  • There is another dead simple way to do this without an options page (but using an option page for items displayed throughout the site, like footer info, can provide a more logical place for clients to enter things).

    Here is an example of a field displaying a newsletter link on the homepage:

    <?php the_field( 'newsletter'); ?>

    Here is the same code but modified to display in the side bar of all other pages of the site:

    <?php the_field( 'newsletter', 2 ); ?>

    The “2” is the post ID of the homepage – that’s it!

    FYI this is hardcoded into my custom theme files.

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

You must be logged in to reply to this topic.