Show search count by post type

You’re essentially running the same query twice, instead of looping over a second query, why don’t you loop over $wp_query? $types = array(); if( have_posts() ) { while (have_posts()) { the_post(); if ( empty( $types[$post->post_type] ) { $types[$post->post_type] = 0; } $types[$post->post_type]++; } wp_reset_postdata(); rewind_posts(); } You’ll notice I added 3 things: The code in … Read more

Localization of WP theme

Wrap the elements of $search and $replace arrays into __() function to get the translated strings: function search_replace_search() { $search_term = esc_attr( apply_filters( ‘the_search_query’, get_search_query( false ) ) ); // Get search term $search = array( __(‘word1’), __(‘word2’) ); $replace = array( __(‘something 1’), __(‘something 2’) ); $replacePairs = array_combine($search, $replace); echo strtr($search_term, $replacePairs); } … Read more

Search for anything in site

Use mark.js, a jQuery plugin mark.js is such a plugin that is written in pure JavaScript, but is also available as jQuery plugin. It was developed to offer more opportunities than the other plugins with options to: search for keywords separately instead of the complete term map diacritics (For example if “justo” should also match … Read more

Check If search query contains something?

After the question’s update, I think that you need to set the canonical URL: add_action( ‘wp_head’, ‘cyb_search_results_canonical_URL’ ); function cyb_search_results_canonical_URL() { if( is_search() ) { $link = get_search_link(); echo ‘<link rel=”canonical” href=”‘ . esc_url( $link ) . ‘”>’; } } And your problem with duplicated content is fixed.

Cannot pass ‘S’ parameter more than two letters

You should use get_query_var instead of $_GET[“s”], this is a built-in wordpress function that retrieves public query variables which would have already been parsed and fed into WP_Query. $args = array(“posts_per_page” => get_option(“posts_per_page”), “post_type” => “astro_game”, “paged” => get_query_var(“paged”), “s” => get_query_var(“s”); Reference: WordPress_Query_Vars

How to pass data to wordpress page (without GET parameter)

It’s completely possible to achieve this by using custom rewrite rules. Right now I don’t have the opportunity to give you the actual code for it, but you can check the documentation for add_rewrite_rule() in the Codex. It’s pretty straightforward if you add a custom parameter to the rewritten URL. Actually, you already have the … Read more

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