Search results thumbnails different size

This is down to difference in the classes output by different types of content in your theme’s search page. The CSS of your theme restricts the width of Posts to 50% of the screen with this rule .blog-area .type-post.size-2×1 { width: 50%; } But for your project content, there is no ‘type-post’ or ‘size-2×1’ classes … Read more

make link to search page

Just like cybmeta in the answer you are linking to said: see Creating a search page in the codex. Read it carefully. Create a Template like described, add a new page in the backend and choose as template your new search-template, that is now in the template-dropdown. Now you can set a link to this … Read more

Redirect to a page while maintaining search query parameters without causing an infinite loop

I achieved this with a couple filters: add_filter( ‘query_vars’, ‘addnew_query_vars’, 10, 1 ); function addnew_query_vars($vars) { $vars[] = ‘r’; // var1 is the name of variable you want to add return $vars; } function redir_cat_match($a) { global $wp_query; if ($wp_query->is_main_query() && $wp_query->is_search()){ if ($wp_query->query_vars[‘s’] != “”){ if ($_GET[‘r’] != ‘0’){ if (!empty($wp_query->posts[0])){ $s_value = $wp_query->query_vars[‘s’]; … Read more

ajax stopped working when not logged in wordpress

Try to output the debug query Find fragment $the_query = new WP_Query( array( ‘posts_per_page’ => 5, ‘s’ => esc_attr( $_POST[‘keyword’] ) ) ); if( $the_query->have_posts() ) : Replaced by $the_query = new WP_Query( array( ‘posts_per_page’ => 5, ‘s’ => esc_attr( $_POST[‘keyword’] ) ) ); echo (string)$the_query->request; if( $the_query->have_posts() ) : Perhaps some hooks are triggered … Read more

Create a post automatically if search result has zero results

Assuming you are using the standard WordPress search, you can get the searched number with get_search_query So this code will create a new draft post if no results were found for the search: $match = get_page_by_title( sanitize_title( get_search_query() ), OBJECT, [‘post_type’ => ‘post’] ); if ( empty( $match ) ) { wp_insert_post( [‘post_title’ => sanitize_title( … Read more

Search function – problem with whole words

Exact means exactly that – the whole field must match, not just a word in the field. To get whole words that are part of the field, remove ‘exact’ => 1 Add this if ($_POST[‘terms’]) { $keyword = sanitize_text_field( $context[‘terms’] ); $keyword = ‘[[:<:]]’ . $keyword . ‘[[:>:]]’; $context[‘posts’] = Timber::get_posts(array( // other params here … Read more

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