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

Keep featured content post in homepage with original order

I think you can use the WPQuery $the_query = new WP_Query( array( ‘post__in’ => get_option( ‘sticky_posts’ )) ); ?> <?php if ( $the_query->have_posts() ) : ?> <!– pagination here –> <!– the loop –> <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <h2><?php the_title(); ?></h2> <?php endwhile; ?> <!– end of the loop –> <!– … Read more

Get posts from sites in Multisite?

The WordPress function switch_to_blog() expects an integer as an input parameter. You can read more about it in the Codex: http://codex.wordpress.org/Function_Reference/switch_to_blog Please try this kind of structure instead: // Get the current blog id $original_blog_id = get_current_blog_id(); // All the blog_id’s to loop through $bids = array( 1, 2 ); foreach( $bids as $bid ) … 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

What are all the available parameters for query_posts?

Below is everything from WordPress 3.0.1 found in the parse_query() function of /wp-includes/query.php (lines 1246-1550). However, it’s possible for a plugin to add parameters and so a list can never be fully complete: attachment attachment_id author author_name cat category__and category__in category__not_in category_name comments_popup day error feed hour m minute monthnum name order orderby p page_id … Read more

Nested meta_query with multiple relation keys

The question was for WordPress 3.0, but just in case someone has the same question for a more recent version, from WordPress Codex: “Starting with version 4.1, meta_query clauses can be nested in order to construct complex queries.” https://developer.wordpress.org/reference/classes/wp_query/#custom-field-post-meta-parameters So, that query should work on the current WordPress version.

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