wp_query List 20 posts from listings category

Wait a minute... This content is very very old. We no longer sell or support this theme version. New Topics
  • Version 9
    Gavin Hammond
    0 points

    I want to list 20 posts from a category called networks. I do not want to use the shortcode, as I need to use a new template style. So i want to create a function to list 20 posts in the category networks. What should be my post type, taxonomy, and terms?

    What do I need to change in my arg:

    add_shortcode( ‘list-posts-basic’, ‘rmcc_post_listing_shortcode1’ );
    function rmcc_post_listing_shortcode1( $atts ) {
    $query = new WP_Query( array(
    ‘post_type’ => ‘listings’,
    ‘posts_per_page’ => -1,
    ‘order’ => ‘ASC’,
    ‘orderby’ => ‘title’,
    ‘taxonomy’ => ‘networks’,
    ) );
    if ( $query->have_posts() ) { ?>
    <ul class=”networks”>
    <?php while ( $query->have_posts() ) : $query->the_post(); ?>
    <li id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>
    “><?php the_title(); ?>

    <?php endwhile;
    wp_reset_postdata(); ?>

    <?php $myvariable = ob_get_clean();
    return $myvariable;

    August 13, 2017 at 10:24 pm
  • Josh njenga
    0 points
    Platinum User
    Bronze User Silver User Gold User Platinum User
    Members Only Content

    This reply is for PremiumPress customers only.

    Login Now
    August 14, 2017 at 2:44 pm