Search a meta field for a value in all posts

WP_Query will return a WP_Query object. An object will never match the string $ip that you are comparing it to. What you need to be doing is checking whether results were returned, which you can do by checking the found_posts property: $ip = $_SERVER[‘REMOTE_ADDR’]; $query = new WP_Query( array( ‘ignore_sticky_posts’ => true, ‘meta_key’ => ‘voted_IP’, … Read more

search does not yield access restricted results

If you setting the posts to private in WordPress, you can add this to your functions.php file: function include_private_in_search( $query ) { // not an admin page and is the main query if (!is_admin() && $query->is_main_query()){ $query->set( ‘post_status’, array ( ‘publish’, ‘private’ ) ); } } add_action( ‘pre_get_posts’, ‘include_private_in_search’ ); Then you can format the … Read more

Is it good practice to search for custom posts based on custom field values?

This sounds like the perfect use case for Custom Taxonomies. And unless you plan to customize the admin backend, the Codepress Admin Columns plugin could be useful for filtering the posts using those new taxonomies. Edit (2014.01.23): Yes, you could build a “search form” where you would list the available taxonomies. The get_categories() function will … Read more

Change the search URL

From WPEngineer (with edits): Add the following to functions.php in your theme: function fb_change_search_url_rewrite() { if ( is_search() && ! empty( $_GET[‘s’] ) ) { wp_redirect( home_url( “/busca/?s=” ) . urlencode( get_query_var( ‘s’ ) ) ); exit(); } } add_action( ‘template_redirect’, ‘fb_change_search_url_rewrite’ ); Add the following to your htaccess file: RewriteCond %{QUERY_STRING} ^s=(.*)$ [NC] RewriteRule … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)