add_query_vars does not work
add_query_vars does not work
add_query_vars does not work
I found this and it works. The big difference is that it checks if $post count == 0 and the creates the virtual page which will then allow all the other queries to function as normal. <?php /* Plugin Name: Virtual Page Plugin URI: http://davejesch.com Description: Create a virtual page with content Author: Dave Jesch … Read more
Ok then, I actually was getting the subcats with the wrong method. in $parent_cat = get_cat_ID( $cat_name ); $cat_name wasn’t a name but un slug. First mistake. So I corrected with $parent_cat = get_category_by_slug( $cat_slug ); The final code is : // Get the parent cat thanks to the page’s cat slug $parent_cat = get_category_by_slug( … Read more
using next-page and previous page inside a wp_query
Do I see that right, that you are doing a WP_Query for every single post, you want to retrieve? That is highly inefficient, you can use the post__in argument supplied by WP_Query. (http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters) foreach ( $urls as $url ) { //echo $url[“mymeta_url”]; foreach ( $url[‘mymeta_slider’] as $u ) { //echo “$u<br> “; shows post id … Read more
Your first example also needs the orderby parameter set, otherwise it defaults to standard date order: $my_query = new WP_Query( array( ‘post_type’ => ‘slider’, ‘post__in’ => $posts, ‘orderby’ => ‘post__in’ ) );
I fixed it by removing all the items in the item class and adding a little <?php $i=1; while ($i <= 1) { ?> <div class=”col-md-6 nopadding view view-ninth” style=”padding-left:4px; padding-right:4px;”> <?php the_post_thumbnail(‘large’); ?> <div class=”content”> <h2><?php the_title() ;?></h2> <p><?php $excerpt = get_the_excerpt(); echo string_limit_words($excerpt,15) . ‘…’; ?></p> <a href=”#” class=”info”>Read More</a> </div> </div> <?php … Read more
From the codex http://codex.wordpress.org/Class_Reference/WP_Query: $args = array( ‘post_type’ => ‘my_custom_post_type’, ‘meta_key’ => ‘age’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ => ‘age’, ‘value’ => array(3, 4), ‘compare’ => ‘IN’, ) ) ); $query = new WP_Query($args); Look at the meta_query section. you can define the key and then all the possible … Read more
The ‘wp_insert_post’ action is fired for each post that is inserted and passed the ID of the inserted post to the callback function, so I think your $wpdb query is unnecessary – in fact, I think you’re running the “custom function” portion for all published posts, not just the inserted post (which may or may … Read more
WP_Query Sorting Posts by month … timeline effect