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.

If No Search Results, Show Posts from Alternate Search Query

I’ve never seen it done before but the logic of the PHP IF/ELSE should mean you could simply plug a new query in after the ELSE: if ( have_posts() ) : while ( have_posts() ) : the_post(); get_template_part ( ‘templates/post’, ‘main’ ); endwhile; else: $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) : … Read more

get_the_foo() in the loop – does it perform another query?

Query results for posts, terms, and metadata get placed in cache. If a function is called that accesses data from previously queried objects within the same request (or you’re using a persistent cache mechanism that maintains data across requests), it will not trigger another query and will instead fetch the data from cache.

WooCommerce – Query for ordered products

Fixed query select p.ID as order_id, p.post_date, i.order_item_name, max( CASE WHEN im.meta_key = ‘_product_id’ and i.order_item_id = im.order_item_id THEN im.meta_value END ) as Prod_ID from wp_posts as p, wp_postmeta as pm, wp_woocommerce_order_items as i, wp_woocommerce_order_itemmeta as im where p.post_type=”shop_order” and p.ID = pm.post_id and p.ID = i.order_id and p.post_date BETWEEN ‘2016-01-14 00:00:00’ AND ‘2016-01-14 23:59:59’ … Read more

Change all http to https in mysql databse?

I should think that you can use phpAdmin Find and Replace where you find “http://www.example.com” and replace with “https://www.example.com“. This should handle all internal linking (if blog, then internal linking as well as images, etc.). It would not cover relative addressing like “//www.example.com”. In the case of WordPress, this would be done on the wp_posts … Read more

How to modify the query to exclude posts by slug?

You can get the post ID from the slug with the url_to_postid() function: $ID = url_to_postid(slug); then just exclude the ID from your query: query_posts(array(‘category_name’ => ‘Mycat’, ‘posts_per_page’ => -1, ‘post__not_in’ => $ID )); You can create an array of post IDs if you need to exclude multiple pages.

view queries made?

See this codex page. in wp-config.php: define(‘SAVEQUERIES’, true); then in your template: if (current_user_can(‘administrator’)){ global $wpdb; echo “<pre>”; print_r($wpdb->queries); echo “</pre>”; } or without the above SAVEQUERIES, you can still see just the main query: global $wp_query; echo $wp_query->request; or to see all of $wp_query: <pre> <?php print_r($wp_query); ?> </pre>

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