Exclude in search post and include only 3 pages

you’re using $query->set(‘post_type’, ‘post’); to only include posts. What you can do is make it an array to include the post type and those specific page IDs you want. Here’s an example code: function custom_search_filter($query) { if ($query->is_search() && !is_admin() && $query->is_main_query()) { $query->set(‘post_type’, ‘post’); // Add the IDs of the pages you want to … Read more

How to capture number input from wordpress form into acf field in woocommerce

Try using the wpuf_add_post_after_insert hook. This hook gets triggered right after a post is created using WPUF, which means it might be a more appropriate time to save additional data, like the phone number: add_action(‘wpuf_add_post_after_insert’, ‘update_product_acf_field_guest_submission’, 10, 3); function update_product_acf_field_guest_submission($post_id, $form_id, $form_settings) { // Check if the form ID matches the specific form where the … Read more

How to make my logged-in user-role shortcode displaying name instead of slug?

Based on what you wrote, you should use instead : if ( ! is_admin() ) { function get_user_role() { global $wp_roles; $user = wp_get_current_user(); $roles = ( array ) $user->roles; foreach ( $roles as $role ) { $user_role=”<p>” . $wp_roles->roles[ $role ][‘name’] . ‘</p>’; } return $user_role; } add_shortcode( ‘display_user_role’, ‘get_user_role’ ); } It works … Read more

Adding Author Filter to CPTs

This isn’t a WordPress problem, it’s a programming logic mistake in this if statement: if( ‘booking’ || ‘ticket’ !== $post_type ) { This code is the same as this: if( ( ‘booking’ != false ) || ( ‘ticket’ !== $post_type ) ) { Which in plain language is: If “booking” is a truthy value, or … Read more

File not found.