• Resolved lljb3

    (@lljb3)


    Can a component be used in a template file? Is there a shortcode of sorts that is used or would I have to loop thru it as a custom post?

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

    (@lljb3)

    I answered my own question.

    It’s a post type, specifically named component. Just loop this like any other WP_Query loop.

    <?php
        /**
         * Component Loop
         */
        $args = array(
            'post_type'=>'component',
            'posts_per_page'=>1,
        );
        $query = new WP_Query( $args ); 
        if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
    ?>
        <?php the_content(); ?>
    <?php endwhile; endif; ?>

    Anyone can use this code to their desire. Please look up WP_Query looping if you need to expand the arguments.

Viewing 1 replies (of 1 total)
  • The topic ‘Component Used in Template Files’ is closed to new replies.