Limit search field to just search a custom post type with custom fields

post_title isn’t a valid argument to WP_Query. If you dump the SQL you will see that it is ignored: string(189) “SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type=”investigator” AND (wp_posts.post_status=”publish”) ORDER BY wp_posts.post_title ASC LIMIT 0, 6″ You can use name (or pagename) instead, but you cannot push raw SQL through like that. It … Read more

search form leads to 404

Don’t submit directly to search.php. WordPress probably will not know what to do with that. You will have the same issue submitting directly to any theme file. WordPress should pick up on the s parameter and process the search correctly if you just leave out the action attribute like so: <form id=’searchform’ method=’get’> Untested, but … Read more

Change the search icon in twenty fourteen

This is more of a simple CSS question than actually related to WordPress. However, you need to change your style.css. As TwentyFourteen does not use images, but pseudo css-classes, you need to change this as well: .search-toggle { background: #fff url(‘http://www.citizen-science.at/wordpress/wp-content/themes/cs/img/search-icon.png’) no-repeat; background-size: 30px; background-position: 10px; } .search-toggle:before { content: “”; } By the way, … Read more

Understanding WordPress Search

The default search is handled by WP_Query mostly by a method called parse_search(), which is triggered by the s parameter. You can search the source of WP_Query for is_search and piece together a few other bits and pieces. Or you can just create a query… $s = new WP_Query(array(‘s’ => ‘test’)); … dump the SQL… … Read more

Custom theme won’t use search.php

Why you are using this filter code, WordPress will still use searchform.php code, without it? Further, it could be some issue with the loop code within search.php. Twentyfourteen theme looks for content-[post-format].php file. Do you have one in you theme root? get_template_part( ‘content’, get_post_format() ); try using this simplified loop in search.php … <?php if(have_posts()) … Read more

Search Results Page – Displaying Custom Meta Fields

You’ve got a missing ) and you’re passing true as a string and not a boolean value. So this line: $pName = get_post_meta($post->ID, $productName, ‘true’; Should in fact be: $pName = get_post_meta($post->ID, $productName, true); In light of your update why not do something like: echo ‘Product Name: ‘. $pName[‘productName’][0]; echo ‘Location: ‘. $pName[‘locationName’][0]; echo ‘Address: … Read more

CPT, meta-data, url parameter

The good answer was from @Milo, but he haven’t posted any code, so I post here my result, for people coming here for the right answer. /* Add query var to authorized query var… */ add_filter( ‘query_vars’, ‘add_spectacles_query_vars’ ); function add_spectacles_query_vars( $query_vars ) { $query_vars[] = ‘spectacles-year’; $query_vars[] = ‘spectacles-month’; $query_vars[] = ‘spectacles-day’; return $query_vars; … Read more