Home Forums Front-end Issues How to display post data from another page?


How to display post data from another page?

  • Hello there I have a home page (ID=8) where I have the following displaying an article title from another post object:

    <h5 class=”card-title”><?php echo $front_page_education_section_related_post->article_title ?></h5>

    I am trying to figure out how I can now reference that from a different page?

    I see from the documentation that his example will display a field value from the post with an ID of 123:
    <p><?php the_field(‘field_name’, 123); ?></p>

    However, I have been struggling to do the same with the field I am trying to show from another page. I did trying something like the following which includes the homepage ID.

    <h5><?php the_field(‘front_page_education_section_related_post->article_title’, 8); ?></h5>

    Thanks for any help anyone might be able to provide here. I am new to php.

  • To clarify – this is for a newspaper. The homepage has sections where the editor can pick where different articles go. The articles displayed on homepage reference posts that are articles. The front page education section has a custom field ($front_page_eductation_section_related_post) where the editor can pick which article (post) he would like to choose to highlight for that section. There is another page in the site that is entirely dedicated to Education related articles. It would be great if the main article displayed on the Education page reflected what was chosen for the Education section on the homepage (ID=8).

  • I am actually thinking the ACF Pro Plugin might do the trick with the Options page allowing for global values

  • Not sure I understand.

    I think you have a relationship or a post object field that is on the home page. On the home page you get the relationship or post object field and then show a custom field that is on the post indicated in the relationship or post object field?

    Do I have that right?

    If not, please explain in more detail.

    An options page would be a good way to do this if you want to show the same thing in multiple pages, but if I understand what you want to do (see above) it can be done without using an options page.

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

You must be logged in to reply to this topic.