Doesn't work with custom queries ?
-
Hello,
I’m trying to make this ^plugin work with custom post types and custom queries.
Here are my snippets :Custom post type registration :
<?php function create_post_type() { register_post_type('editorial-posts', array( 'labels' => array( 'name' => __( 'Editorial posts' ), 'singular_name' => __( 'Editorial posts' ) ), 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'editorial-posts' ), 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => 4, //'menu_icon' => '', 'supports' => array( 'title','editor','thumbnail' ), 'taxonomies' => array('category', 'post_tag') ) ); } add_action( 'init', 'create_post_type' ); ?>The query :
<?php // Get the parent cat thanks to the page's cat slug $parent_cat = get_category_by_slug( $cat[1] ); $args = array( 'type' => 'post', 'child_of' => $parent_cat->term_id ); // child cats $categories = get_categories( $args ); // loop on the child cats to get the sub cats object if ($categories) {?> <!-- THE TITLE --> <div class="text-seperator"> <h2>Sector's programs</h2> </div> <ul class="sc_accordion"> <?php foreach ($categories as $key => $value) { $args = array( 'post_type' => 'editorial-posts', 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => array( $value->slug ), 'include_children' => false ), array( 'taxonomy' => 'post_tag', 'field' => 'slug', 'terms' => array( 'short-description' ) ) ) ); $program_desc_short = new WP_Query( $args ); /*echo '<pre>'; var_dump($program_desc_short); echo '</pre>';*/ ?> <?php if ($program_desc_short->have_posts()) : $program_desc_short->the_post() ?> <li><a class="sc_accordion-btn" href="#"><?php echo $value->name ?></a> <div class="sc_accordion-content"><?php the_content(); ?> <?php edit_post_link(__('Edit This'),'<p class="edit-link">' ,'</p>'); ?> <a href="<?php echo '/sectors/'.$value->slug ?>" class="btn small-btn right">Read more</a> </div> <?php endif; wp_reset_query(); } ?> </ul> <?php } ?>I checked out that I was using hierarchical->false, but still can’t re-order posts.
Can you help please ?
Thansk
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
The topic ‘Doesn't work with custom queries ?’ is closed to new replies.