Date query year and month OR just year

You have not stated how the selection works, but you need to have some kind of conditional set when a specific month is selected and when a year archive is selected. I also do not know where get_the_time comes in or its relevance to the query. But anyways, there are some other really big issues … Read more

How to count get_users query?

when you use get_users() it retrieves an array of users matching the criteria given in $args which means you can simply use PHP’s count() function e.g: $users = get_users($args); $number_of_users = count($users);

search through post-type attachments titles

You should try applying the s(search) as parameter for your custom query. See this example here: $query = new WP_Query( ‘s=keyword’ ); and you can then apply normal loop to iterate through your results. This also performs string match same as like operator %keyword% you mentioned in comment for @Ravs’ answer. Refer documentation here.

$wpdb->get_var not returning a result

$wpdb->get_var returns a single variable, but your SQL statement has SELECT * which returns a row of multiple columns. You need to change your SQL statement to SELECT ID … instead of SELECT * …

Show All Posts Insert Edit Link

See if this doesn’t do it: First, the callback for that Ajax search (the wp_link_query method in wp-includes/class-wp-editor.php) suppresses the normal filters. We have to turn them back on for this particular query. function undo_suppress($qry) { global $_POST; if (isset($_POST[‘action’]) && ‘wp-link-ajax’ == $_POST[‘action’]) { $qry->set(‘suppress_filters’,false); } } add_action(‘pre_get_posts’,’undo_suppress’); Now we can use the posts_where … Read more

How to tell if $query_var isset?

use the indentical comparison operator: if(get_query_var(‘cls’) !== ” && get_query_var(‘ch’) !== ”) { mcs_textbook_chapter($dialect, $cls, $ch); } elseif(get_query_var(‘cls’) !== ”) { mcs_textbook_chapter($dialect, $cls); } else { mcs_textbook($dialect); }

Show recent products first but “sold out last” in query

If we only have two stock statuses, namely outofstock and instock, we can very easily achieve sorting with pre_get_posts add_action( ‘pre_get_posts’, function ( $q ) { if ( !is_admin() // Target only front end && $q->is_main_query() // Only target the main query && $q->is_post_type_archive() // Change to suite your needs ) { $q->set( ‘meta_key’, ‘_stock_status’ … Read more

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