I wrote this, it works by saving variables in a parent loop and using thin in a child loop that checks IDs using an if statement… it is not the cleanest solution, but it does work. If anyone has a better suggestion I am all ears
<?php
$theID = $post->ID;
$posts = get_posts(array(
'posts_per_page' => -1,
'post_type' => 'sas_news'
));
if( $posts ): ?>
<?php foreach( $posts as $post ):
setup_postdata( $post );
?>
<?php
$pn = get_the_title();
$pid = get_the_ID();
$purl = get_the_permalink();
$pex = get_the_excerpt();
$pimg = get_the_post_thumbnail_url($pid,'full');
?>
<?php $post_objects = get_field('link_to_sas_member'); ?>
<?php if( $post_objects ): ?>
<?php foreach( $post_objects as $post): // variable must be called $post (IMPORTANT) ?>
<?php setup_postdata($post); ?>
<?php if($theID == get_the_ID($post_object->ID) ){ ?>
<div class="post-item">
<div class="ptit">
<a href="<?php echo $purl; ?>"><h3>
<?php echo $pn; ?>
</h3></a>
</div>
<div class="pex">
<?php echo $pex; ?>
</div>
</div>
<?php } ?>
<?php endforeach; ?>
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
<?php endif; ?>
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
This option will show the fields on the post page, not on the category page.
You need to choose the page template as the category
Could you clarify?
So in the acf group, create your fields.
Then in your rules set “post taxonomy” to equal the taxonomy you want the fields to show for.
When creating your posts, if you checkbox the taxonomy/category you chose the fields will show.
To troubleshoot:
1. check that the fields are showing further down the page, sometimes they will show but they will only appear at the bottom of the post unless you set the priority
2. Try saving the post to see if the fields show
Post a screen shot of your rules so we can see 🙂
Got it!
function my_acf_save_post( $post_id ) {
// get new value
$value = get_field('logo');
// do something
update_field('logo_url', $value);
}
add_action('acf/save_post', 'my_acf_save_post', 20);
Deleted the page and rebuilt.
All seems to work fine now. Odd.
Legend! Thank you.
I was being an absolute fool and you were spot on! Thanks for answering that.
Is there a way to show the ACF group on the actual product edit page if the category is checked?
Currently, this adds the ACF group to the category editor, I need this to show if a user check-boxes the relevant category.
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.