Home › Forums › Backend Issues (wp-admin) › Showing fields in page template and category.php
Hi!
I have a page template called “Additions” and i have created “Additions” Field Group and fields show properly both in WP dashboard and on frontend page.
But, i would wish to show those same fields (values filled on Additions page) on blog category page (which is using category.php).
So, in field group options i have selected, beside Additions page template, all taxonomies (because i want to show those fields on all category pages) but they dont show up… I have also tried “Post Category”, “Post Taxonomy” but those fields just dont want to show up on category page…
Do you want to add values to the category or do you want to show the values from each post on the category page?
Hi John,
thank you for getting back to me, it means a lot.
I would like whatever content i enter on “Additions” page to show up, not only on Additions page, but also on category.php and single.php page.
In additions page i am using this to echo the content:
<?php
$call_to_action = get_field('call_to_action');
if( $call_to_action ): ?>
<div class="cta" style="background-image:url('<?php echo $call_to_action['image']; ?>')">
<div class="container">
<div class="row">
<div class="col-12">
<div class="card text-center">
<h1><?php echo $call_to_action['title']; ?></h1>
<h3><?php echo $call_to_action['subtitle']; ?></h3>
<a href="<?php echo esc_url( $call_to_action['link']['url'] ); ?>" class="btn btn-primary"><?php echo esc_html( $call_to_action['link']['title'] ); ?></a>
</div>
</div>
</div>
</div>
</div>
<?php endif; ?>
But since i am just starting with PHP i really dont know how to show it on those pages as well… I tried following this article https://www.advancedcustomfields.com/resources/how-to-get-values-from-another-post/ but i really dont know how to implement this…
Any help would mean a lot…
Thanks!
As long as you’re in “The Loop” (https://developer.wordpress.org/themes/basics/the-loop/) that is showing posts you show fields on a category page the same way you show them on a single page.
// the category page should have a loop
while (have_posts()) {
the_post();
// as long as you show the field here it should work
the_field('some-field-name');
}
I understand, those fields will show up on “Additions” because field group is created for Additions template.
But if i paste this code into category.php, nothing shows up…
How can i tell ACF to display entered values from Addition page on category page as well?
English isnt my first language so i dont know am i explaining it properly 😀
The topic ‘Showing fields in page template and category.php’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.