Tell us what you are trying to do? Build content template display custom fields in custom content type.
Is there any documentation that you are following? No
Is there a similar example that we can see? hidden link
Only the first case of using the service field shows the value (the second is simply a duplicate block).
If I move preferred location first, it's value shows and service does not.
(There should also be a number of values under personal information).
I have disabled in caching.
What is the link to your site? hidden link
Hi,
Thank you for contacting us and I'd be happy to assist.
To troubleshoot this, I'll need to see how these custom fields and the content template are set up, in the admin area.
Can you please share temporary admin login details, in reply to this message?
Note: Your next reply will be private and it is recommended to make a complete backup copy, before sharing the access details.
regards,
Waqar
Thank you for sharing these details, but, I'm getting the message:
"Error: The username {*****} is not registered on this site. If you are unsure of your username, try your email address instead."
Can you please check the username and password again?
Note: I've set your next reply as private.
The new access details worked.
I've noticed that the select fields "Service" and "Prefered Work Location" are set to use the "wpt_field_options" filter, to programmatically generate the options.
The limitation of using this filter is that the when the value from these fields is shown using the dynamic content option, the output of fields that come after it, is affected.
To overcome this, you can remove the two advanced heading blocks for these fields, and instead add them using the shortcodes in a "Fields and Text" block, like this:
<p><strong>Service:</strong> [wpv-post-title item="[wpv-post-field name='wpcf-requested_service']"]<p>
<p><strong>Preferred Location:</strong> [wpv-post-title item="[wpv-post-field name='wpcf-prefered-work-location']"]</p>
I hope this helps and please let me know if you need any further assistance around this.
Has this bug been reported or should I?
Thanks
Thanks for writing back.
During some further tests, it emerged that the use of "WP_Query" in the plugin file "service-requests.php" is responsible for this unexpected behavior.
In this file, the "WP_Query" function is being used for generating the options for the fields "Service" and "Prefered Work Location" fields, which interferes with the main query/loop of the page too.
Instead of using the "WP_Query" function, you can use the "get_posts" function.
( ref: https://developer.wordpress.org/reference/functions/get_posts/ )
Here is how the updated function "service_requests_possible_services" for the "Service" field will look like:
add_filter( 'wpt_field_options', 'service_requests_possible_services', 10, 3);
function service_requests_possible_services( $options, $title, $type ){
switch( $title ){
case 'Service':
$options = array();
$options[] = array(
'#title' => 'Please Select Service',
'#value' => 0
);
$args = array(
'post_type' => 'service',
'posts_per_page' => -1,
'post_status' => 'publish',
'orderby' => 'title',
'order' => 'ASC',
);
$posts_array = get_posts( $args );
foreach ($posts_array as $post) {
$options[] = array(
'#value' => $post->ID,
'#title' => $post->post_title,
);
}
break;
}
return $options;
}
Similarly, you can update the function "service_requests_possible_locations" for the field "Prefered Work Location" too.
My issue is resolved now. Thank you!