Agreed with what John said.
Simply put, they are working fine on your sub-sites, there was no reason for you to sync them.
You cannot do it natively; as John mentioned, there is a plugin.
Though ACF has its resource on how to do so with some coding know-how.
https://www.advancedcustomfields.com/resources/bidirectional-relationships/
Very nice, John I didn’t think to use wp_head, I was so focused on header.php.
Very nice indeed! Thank you for this!
Is this what your looking for?
It seems like you have a ways to go.
To easily get the image behind the text using a background style with css would be the best way to go. You have to make div elements or other elements though, having simply data but not way to target it doesn’t help.
Example:
<?php while( have_rows(‘grouped_fields’) ): the_row(); }
?>
<style>
.modal-wrap{
display: flex;
flex-flow: column;
justify-content: center;
align-items: center;
}
</style>
<div class="modal-wrap" style="background: url("<?PHP echo $image_url; ?>") 50% 50% no-repeat">
<h2><?php the_sub_field(‘title’); ?></h2>
<p><?php the_sub_field(‘date’); ?></p>
<p><?php the_sub_field(‘time’); ?></p>
<p><?php the_sub_field(‘location’); ?></p>
</div>
<?php endwhile; ?>
get_field() will only work on the pages of the custom post type. This is more to do with what loops are running on which pages.
You can access those fields a couple ways, by using get_field( ‘field_name’, ‘ID of CPT post’ ) or you can loop through using a wp_query loop and get those fields from that Custom post type.
Yes indeed, if you are using the updated Block method for ACF Pro that uses the WordPress block.json then everything block.json can do you can now do too.
"editorScript": "file:./index.js",
"script": "file:./script.js",
"viewScript": [ "file:./view.js", "example-shared-view-script" ],
https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/
Multiple ways to do it, you can position everything with absolute so that it all overlays the same div block but this can get a bit messy.
Most likely if you just take the image and use that as a background image and do some inline CSS to get that background image then you can position the rest of the items within the div block.
Though without going into a huge amount of detail this isn’t really anything to do with ACF this is knowing front-end development and in this case CSS.
https://freefrontend.com/css-cards/ Here is some helpful cards you could reference
$my_query = new WP_Query($args));
if($my_query->have_posts()) {
while($my_query->have_posts()) {
$my_query->the_post();
/* Add all the fields your checking for here - I'm sure there is a prettier way to do this */
if( !empty(field_1) || !empty(field_2) || !empty(field_3) || !empty(field_4) ) {
true;
/* Do whatever you want now */
} else {
/* Do Nothing? This has an empty field */
false;
}
}
}
You can check for it when the loop it output; this way you’re not looping through every time to check each specific field, you only loop through once and don’t show it on output.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.