• Resolved nipait

    (@nipait)


    Hi all,

    I’m trying to create a shortcode to be included into the body of some pages that should reproduce the stream of the posts of a specific category (the same as I go to mydomain.com/category)
    So far I’m working on this

    /**
     * Permette di richiamare l'elenco dei post con categoria=Libri nel post Libreria
     */
    function elenco_libri_post( $atts )
    {  
       
    $catquery = new WP_Query( 'cat=72&posts_per_page=5' );
    $a = '<ul>';
    while($catquery->have_posts()) : $catquery->the_post();
    
    $a += '<li><h3><a href="' . the_permalink() . '" rel="bookmark">' . the_title() . '</a></h3><ul><li>' . the_content() . '</li></ul></li>';
    endwhile;
    $a += '</ul>';
    wp_reset_postdata();
        return $a;
    }  
    add_shortcode("elenco-libri-post", "elenco_libri_post");  

    But I can’t understand by reading the code what is the specific part that can output the list (and the navbars of course) to add to my post the list.

    Does anyone can help me please?

    Thank you ??

Viewing 1 replies (of 1 total)
  • Thread Starter nipait

    (@nipait)

    I’ve just build the page into the description of the category and edited with several lines o CSS.

    the problem can be considered resolved.

Viewing 1 replies (of 1 total)
  • The topic ‘[Tracks-others] creating shortcode with template of list of posts of a category’ is closed to new replies.