Tagged: x
-
AuthorPosts
-
October 24, 2016 at 6:50 am #1228227
keith sParticipantI used some code from another thread to add a sidebar to single product pages in my template layout. I inserted the code into my child theme functions.php file and it worked great. The only issue is it now creates an “invalid post type” error when searching products in the dashboard. The first search after you refresh will work and then subsequent searches produce the error. I tested it by removing the code and the product search mechanism works fine.
Please advise. Thank you.
http://www.midweststeeringdev.com
All versions of x theme, WP and related plugins are up to date.*I will follow up with credentials in a private message.
October 24, 2016 at 6:56 am #1228234
keith sParticipantThis reply has been marked as private.October 24, 2016 at 7:55 am #1228293
ThaiModeratorHi There,
Please find this code:
add_filter( 'pre_get_posts', 'custom_search' ); function custom_search( $query ) { if ( $query->is_search ) { $query->set( 'post_type', array( 'product' ) ); } return $query; }And change to this:
add_action( 'pre_get_posts', 'custom_search' ); function custom_search( $query ) { if(is_admin()){ return $query; } if ($query->is_main_query() && $query->is_search ) { $query->set( 'post_type', array( 'product' ) ); } return $query; }Hope it helps 🙂
October 24, 2016 at 8:40 am #1228338
keith sParticipantYou’re awesome! Works great! Thank you.
October 24, 2016 at 10:05 am #1228427
ThaiModeratorGlad we’re able to help 🙂
If you need anything else please let us know.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1228227 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
