wp_query on search results page showing all results every time

Don’t create a new WP_Query. As per the template hierarchy WordPress uses the search.php template in your theme for the search results page. This template just needs to contain The Loop, and the only posts inside that will be your search results. See Twenty Seventeen’s search results template as an example: https://github.com/WordPress/twentyseventeen/blob/master/search.php

How to get current user ID in array meta_value?

WP_User_Query is a user search. This sentence… But I need to echo only those users name whose meta_key= something but meta _value is equal to current user ID. … suggests that that is not really what you want. I think you can accomplish this with: $current_user = wp_get_current_user(); $meta = get_user_meta($current_user->ID, ‘Something’, true); if (!empty($meta)) … Read more

How to insert a variable into a query parameter?

Errr, are you talking about this: $variable = get_field(‘loop_category’); $args = array( ‘category_name’ => $variable, ); $catquery = new WP_Query($args); while ($catquery->have_posts()) { $catquery->the_post(); // Do your thing } If so, this is basic PHP and has nothing to do with WordPress – even though this is used in its context.

paged query leads to 404? [duplicate]

A couple of points you should try out: Remove the ‘paged’ => $loop->query_vars[‘paged’] from your $pagination array. It’s not a parameter in the docs. Remove the ‘base’ => @add_query_arg(‘paged’,’%#%’) from your $pagination array. I believe WordPress catches the paged parameter using the default page parameter. Which is it’s default. Here are the docs for the … Read more

Can’t See Media Queries with Inspect Tool [closed]

I think I may have the solution below 🙂 Try adding this to your CSS file: @media screen and (max-width: 479px) { .sow-slider-base ul.sow-slider-images li.sow-slider-image.sow-slider-image-cover { background-image: url(‘http://www.thousandgirlsinitiative.org/wp-content/uploads/2016/04/Wendy-mobile.jpg’) !important; } #why-sponsor-homepage { padding: 20px; } } All I have done here is removed the space between url and the link of the image and it … Read more

Font size on image captions on mobile

Please Use font-size: 2.5vw; it is responsive and set according to size. .wp-caption .wp-caption-text { **font-size: 16px** !important; color: #000000; text-align: center; background-color: #F2F2F2; padding-top: 1px; margin: 1px; }

Query Concatenation

In SQL statement use placeholders instead of variable: %s (string) or %d (number). The second argument of prepare() is array of variables to substitute into the placeholders. $skill_select = $wpdb->get_results( $wpdb->prepare(” SELECT skill_name, char_id, um_id, c.class_id FROM `wp_ml_skill_class` sc JOIN `wp_ml_skill` s ON (s.skill_id = sc.skill_id) JOIN `wp_ml_character` c WHERE c.class_id = %d AND c.char_id … Read more

how to use transient method?

First, you don’t need a raw SQL query, and by using one you give up all of WP’s optimisations. For example, if you run the query twice, it runs twice. If you had used WP_Query to getch those posts though, it would save them the first time to avoid making additional queries. It’s even possible … Read more

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