What you need to do is edit your template where the title of the post is displayed and add something like
<h1><?php the_title(); ?></h1><!-- this should be somewhere in your templates -->
<?php
if (get_field('subtitle')) {
?><h2><?php the_field('subtitle'); ?></h2>
}
?>
I don’t see anything that sticks out in your code other than the names of the variables that your using, try
<?php
$related_posts = get_field('thanks_related_downloads', $pageid);
if( $posts ): ?>
<?php foreach( $related_posts as $related_post ): ?>
<?php echo get_the_title( $related_post->ID ); ?>
<?php endforeach; ?>
<?php endif; ?>
You should always return something, you will get an error if you don’t always return the array with all of the correct indexes unless you check for the existence of those indexes before you try to use them, but I wouldn’t worry about some of your checking for MS if you’re sure that it is a multisite setup.
// Get custom fields from main blog
function get_tracking_options() {
if (get_current_blog_id() != 1) {
switch_to_blog(1);
}
$custom_fields = array(
'head' => get_field('tracking_head', 'options'),
'body' => get_field('tracking_body', 'options'),
'footer' => get_field('tracking_footer', 'options'),
'menu_html' => get_field('menu_html', 'options')
);
if (ms_is_switched()) {
restore_current_blog();
}
return $custom_fields;
}
Is the field is_category
a checkbox or a true/false field?
Can you provide a screenshot of your field setup so that I can see what you’re working with.
The layout of fields that you’re looking for is not currently possible in ACF, that is a table with the labels on the left and fields on the right.
With ACF5, when setting up a field group in ACF you can set Label placement for a field group to left aligned and this will for the most part create what looks like a table with labels on the left and values on the right.
A repeater would probably not be the right method to create what you’re looking for.
The code that you’re using to populate the select field choices would probably be helpful in this case.
This problem has been reported on and off for URLs in ACF fields and it can happen with text fields as well as URL fields, but has never been resolved because in testing no one has ever been able to reliably recreate the issue.
The best that can be said is that it may have something to do with server/php settings on your live server. To debug this you need to figure out where and why the redirect to a bad page is happening and the only way to do this would be follow the save process of the options page through all of the acf code and figure out where the URL of the ACF field is effecting the URL that WP is trying to redirect to.
What we need is for someone that has to ability to do the debugging to also be able to reliably recreate the issue.
I’m not sure what you’re having a problem with, getting the post parent or showing the random list. So let’s start with the first one.
Where is the value for $post_ID coming from in this statement?
$parentpost_id = wp_get_post_parent_id( $post_ID );
It could be related to the revision thing. If a revision isn’t being saved then is there a place to record who made the change?
You might want to submit a new support ticket https://support.advancedcustomfields.com/forums/topic/_edit_last-not-being-updated-on-when-using-frontend/
You might also want to look into adding an acf/save_post filter and make this update yourself if it’s required.
Create an acf/load_value filter https://www.advancedcustomfields.com/resources/acfload_value/ for the repeater. The value at this point should be an array of repeater rows. You should be able to remove the ones you don’t want and then re-order the array so the indexes are consecutive.
something like:
function remove_old_departures($value, $post_id, $field) {
$new_value = array();
if (is_array($value) && count($value)) {
foreach ($value as $row) {
// logic to decide if your keeping the row
// if you want to keep the row
$new_value[] = $row;
}
}
return $new_value;
}
add_filter('acf/load_value/key=field_123456...', 'remove_old_departures', 10, 3)
I can’t recall ever seeing a topic on trying to put acf values into emails, so this is just a guess. You probably need to include the post ID of where to get the value from, for example the post ID of the order post, and I don’t know if that information is available where you are generating the email. Does WC pass the order/post ID to the mail function?
$tracking = get_field('tracking-code', $post_id);
$carrier = get_field('carrier-name', $post_id);
$date = get_field('pickup_date', $post_id);
<p>Your order has been picked up by <?php echo $carrier; ?> on <?php echo $date; ?>. Your tracking code is <?php echo $tracking; ?>.</p>
I think you’re looking for functionality that is not supplied by the ACF maps field. If this is something that can be done it would likely need to be done through custom coding of a google maps api interface. I have not seen any topics on anyone successfully doing what you’re looking for with ACF. When I’m looking for more complicated google maps functionality I generally go with this https://www.wpgmaps.com/purchase-professional-version/
Have you tried specifying the post ID when getting the fields you want to use for your title?
Instead of
$marca = get_field('brand');
Try
$marca = get_field('brand', $post_id);
What version of ACF are you using? ACF 5 has the ability to add custom fields to specific comment forms. I’m not familiar with WC reviews but it seems this would be an easier path than using ACF form. To be honest, I’m not at all sure that it’s possible to use acf_form() to create comments.
That hook, as I’ve discovered, is run whenever ACF field groups are included on a page, front end or back. Figured it out when I was creating a custom field type and couldn’t get it to work with acf_form().
Maybe there’s something going on elsewhere, but I don’t see anything in that code that would display the content inside both of the if statements. As written only one, or neither of those statements will be true, both cannot be true.
No, ACF expects checkbox fields to be saved as an array in the DB. Why do you need the format changed, maybe there is some other solution.
I think I’m a little confused. I don’t see a function name, but your returning a value and I don’t see where you’re calling a function, for example
// functions.php
function get_tracking_options() {
// your function code here
}
// in template
$custom_fields = get_tracking_options();
echo $custom_fields['body'];
Custom shortcodes are always a possible solution. Yes, you could create your own shortcode and supply parameters to output rows of a repeater.
In ACF5 set Layout to Block OR Row. In SCF4 Set it to Row.
Using acf_form() what you’ll need to do is create something like a radio button field and then add a custom acf/pre_save_post filter https://www.advancedcustomfields.com/resources/acf-pre_save_post/ and set the status of the post in the filter.
Shortcodes in acf are only meant for “Basic” field types.
It is possible to show the value of a basic field type in a repeater if you use the correct field name. Here is how repeater fields are stored
"{$repeater}_{$index}_{$sub_field}"
// $repeater = name of the repeater field
// $index = the row, starting at 0
// $sub_field = name of the sub field
if you do this
$layouts = get_field('field_name', false, false);
I think that $layouts should be an array. It’s length will tell you how many layouts there are and you can set up a counter to keep track of where you are and if you’re at the end. Having the list of layouts you can also look ahead in the array to see what the next layout is.
Enqueue your custom JS and CSS on the hook acf/input/admin_enqueue_scripts
.
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.