0

I'm busy customizing a WordPress site using the standard twentyseventeen theme, and I need to show custom fields (produced per post, by plugin) in the exerpt of each post on the Posts Reading Page, instead of the Content (not being used at all).

I have tried using PHP insertion to show the custom fields in the Content Section, which works on the Post's page, but all PHP functionality is dropped on the Posts reading page, and only HTML remains. Now, I'm thinking of editing the reading page which lists all posts by default, which should sort the problem out - I've managed to get the code running on other PHP pages in editor.

Which physical PHP page in Editor can I edit to include my PHP code, and drop the Content?

WP Posts Page Selection

As per image above, my current Posts page is set as "Bids". I want to edit the back-end which generates the content to display on the Posts Page.

The PHP coding is purely to iterate through all post IDs, getthe relevant fields and echo the looked up custom fields -

See documentation here (Section: Get a value from a specific post): https://www.advancedcustomfields.com/resources/get_field

EXAMPLE:

Site Example

2

home.php is the file in the WordPress template hierarchy which is used for the posts page. However, after looking at the Twentyseventeen theme code on GitHub, there is no home.php file provided which means the index.php will be used instead.

Within index.php Twentyseventeen then uses get_template_part to seperate reusable sections of code. The most general of these is the components/post/content.php which looks to be the file displaying your example above.

You can add your get_field function call around line 57 of components/post/content.php and it will display your post metadata.

  • Perfect! This is exactly what I was looking for. All working as it should, now. – Johan Brink Jan 21 '18 at 11:49
0

Look at the template hierarchy to find the appropriate file (or add a new one).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.