This thread is resolved. Here is a description of the problem and solution.
Problem:
The client needed to apply a PHP filter specifically to the custom post type "event".
Solution:
We recommended modifying the existing function to check the post type before applying the filter. Here's the step-by-step solution:
add_filter( 'icl_job_elements', 'filter_title_for_events_only', 10, 2 );<br />function filter_title_for_events_only( $fields, $post_id ) {<br /> // Check if the post type is 'event'<br /> if ( 'event' === get_post_type( $post_id ) ) {<br /> foreach ( $fields as $field => $value ) {<br /> if ( $value->field_type == "title" ) {<br /> $value->field_translate = 0;<br /> $value->field_data_translated = $value->field_data;<br /> }<br /> }<br /> }<br /> return $fields;<br />}
This code snippet should be added to the theme's functions.php file or a custom plugin. It ensures that the filter is only applied to the title fields of posts with the custom post type "event".
Please note that this solution might be outdated or not applicable to your case. If it doesn't solve your issue, we highly recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please open a new support ticket.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
This topic contains 5 replies, has 2 voices.
Last updated by 9 months, 2 weeks ago.
Assisted by: Bruno Kos.