Tag Info

Hot answers tagged

3

Don't use query_posts. Use a filter on pre_get_posts. function no_front_sticky_wpse_98680($qry) { if (is_front_page()) { $qry->set('post__not_in',get_option( 'sticky_posts' )); } } add_action('pre_get_posts','no_front_sticky_wpse_98680'); By running query_posts you clobber the main query, over-writing it with another query. That is why you ...


2

I did something similar, the technique you need to use is called a meta query. Here is the query I wrote to get posts based on a date value stored as a custom field meta value. query_posts( array( 'post_type'=>'post', 'order'=>'ASC', 'orderby'=>'meta_value_num', 'meta_key'=>'date_event', 'posts_per_page'=> -1, 'meta_query' => array( ...


2

This is essentially a SQL question. The only possible WordPress related component would be if you were asking about database structure, which is in the Codex. Or you could just look at the database itself. The post ID is incremented and never duplicated. The highest IDs are the last added. The query is simple. SELECT * FROM {$wpdb->posts} WHERE ...


1

The cat and category_name parameters for WP_Query display "posts that have this category (and any children of that category)". There are also examples of doing this in the Codex. $query = new WP_Query( 'cat=4' ); // or $query = new WP_Query( 'category_name=staff' ); I am not 100% sure what you mean by "I need all to be autopopulated", but if you want ...


1

use get_page_by_title to get post by title. I check for it on my system $post_exist=get_page_by_title( 'Hello world!', ARRAY_A, 'post' ); if( ! empty( $post_exist ) ) { echo 'title exist'; } else { echo 'title not exist'; } Running successfully. In your case it may be like $title=trim($titles_arr[$i]); ...


1

I've solved the problem myself though it is probably not be the right way to do it. Note that I've had to type "website-address" instead of the actual URL because system here won't let me use more than one URL in a post without more reputation. That makes it quite difficult to convey what's actually going on of course, but there is no choice for that it ...


1

Sticky posts are kept in a serialize array in an option in $wpdb->options with the option_name of sticky_posts. So you will need to pull that option and add an OR to the query. $sticky = get_option('sticky_posts'); $qry = "... OR {$wpdb->posts}.ID IN (".implode(',',$sticky).")";



Only top voted, non community-wiki answers of a minimum length are eligible