Why query_posts() isn’t marked as deprecated?

Essential question Let’s dig into the trio: ::query_posts, ::get_posts and class WP_Query to understand ::query_posts better. The cornerstone for getting the data in WordPress is the WP_Query class. Both methods ::query_posts and ::get_posts use that class. Note that the class WP_Query also contains the methods with the same name: WP_Query::query_posts and WP_Query::get_posts, but we actually … Read more

query_post by title?

functions.php <?php add_filter( ‘posts_where’, ‘title_like_posts_where’, 10, 2 ); function title_like_posts_where( $where, $wp_query ) { global $wpdb; if ( $post_title_like = $wp_query->get( ‘post_title_like’ ) ) { $where .= ‘ AND ‘ . $wpdb->posts . ‘.post_title LIKE \’%’ . esc_sql( $wpdb->esc_like( $post_title_like ) ) . ‘%\”; } return $where; } ?> Then: $args = array( ‘post_title_like’ => … Read more

posts_per_page no limit

-1 is your answer! Look for posts_per_page here. $args = array( ‘post_type’ => ‘post’, ‘cat’ => ‘22,47,67’, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘hide_empty’ => 1, ‘depth’ => 1, ‘posts_per_page’ => -1 ); Important caveat: This can result in a very huge query that can bring the site down. Do this only if you are … Read more

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