Load more posts with multiple queries

Looks like you’re not resetting your query, so WordPress is running a new query on the posts you already got. After your first query add: wp_reset_query(); Always reset after any query that isn’t The Loop. Here’s the codex page on it: http://codex.wordpress.org/Function_Reference/wp_reset_query

Add a class to posts in increments of 2

Filter post_class, use a static internal counter in the filter callback: add_filter( ‘post_class’, ‘wpse_100804_post_class’ ); function wpse_100804_post_class( $classes ) { static $counter = 0; $counter += 1; switch ( $counter ) { case 4: $counter = 0; case 3: $classes[] = ‘extra’; } return $classes; } In your loop template call post_class() like this: while … Read more

Optional Meta Query

All of the real work here is being done by $geoDataStore->getPostIDsOfInRange. That is where the search is done and that is what isn’t returning the results you want. WP_Query just pulls the specified post IDs. There is no reason you should have to abandon that part of the code, though you may want to add … Read more

How Can I Query a Specific Page From a MultiPage paginated Post

WordPress uses the PHP explode function to split the content into a array of ‘pages’. Happens in the setup_postdata function with this code: $pages = explode(”, $content); source So you could do something like : function wpse_103026( $content, $pagenum ) { if ( strpos( $content, ‘<!–nextpage–>’ ) ) { $pages = explode(‘<!–nextpage–>’, $content); return isset … Read more

Search / Filter posts on Title/Content OR Tags

I worked it out myself.. The query I was looking goes like this: SELECT * FROM $wpdb->posts, $wpdb->term_relationships, $wpdb->term_taxonomy, $wpdb->terms WHERE ($wpdb->terms.name LIKE ‘%$s%’ OR $wpdb->terms.slug LIKE ‘%$s%’ OR $wpdb->posts.post_content LIKE ‘%$s%’ OR $wpdb->posts.post_title LIKE ‘%$s%’) AND $wpdb->posts.ID = $wpdb->term_relationships.object_id AND $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id AND $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id AND $wpdb->posts.post_status=”publish” AND $wpdb->posts.post_type=”products” ORDER BY $wpdb->posts.post_date … Read more

do_shortcode within post query

You set $post_slug outside the Loop, so the value never changes. You need to reset that inside the Loop so that it will be reset to each post in turn as the Loop progresses. $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); $post_slug = $post->post_name; echo … Read more

How to go about combining dropdowns / filter queries?

To get you started: you can make a custom form (I never worked with wp_dropdown_categories). When the form is submitted, it gets the input variables and uses them in the query. The form could be something like: <form action=”http://example.com/resultspage” method=”post”> <select name=”categories”> <option value=”categoryname1″></option> <option value=”categoryname2″></option> <option value=”categoryname3″></option> </select> <select name=”tags”> <option value=”tagname1″></option> <option value=”tagname2″></option> … Read more

Sticky post appears twice

What you describe is not an issue but normal WordPress behaviour. When you mark a post as a sticky it will be at the top of the list and it will appear in it’s original postition as well, unless the original position is on the first page. A sticky will appear at the top of … Read more

Making certain categories of CPT not publicly queryable

Sounds like you really just need a filter on pre_get_posts to remove the unwanted terms. Something like this, but I am not sure I understand all the conditions you need so think of it as proof of concept only. function exclude_terms_wpse_117242($qry) { if (is_user_logged_in()) { $tq = array( array( ‘taxonomy’ => ‘your_tax’, ‘field’ => ‘id’, … Read more

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