Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jason Yingling

    (@yingling017)

    So that will depend on your theme, but using Twenty Fourteen as an example it is pretty easy.

    First off you’ll need to use the do_shortcode function, and make sure you call it within the loop.

    So the code you’re inserting will look something like this <?php echo do_shortcode('[rt_reading_time label="Reading Time:" postfix="minutes"]'); ?>

    That’s what you’ll enter into your theme template. For example, in Twenty Fourteen the post meta is contained in the <div class="entry-meta"></div>. So to get the reading time appended to the end of that, you’ll just add your do_shortcode function into the end of the div. Which will give you this in Twenty Fourteen.

    <div class="entry-meta">
    	<?php
    		if ( 'post' == get_post_type() )
    			twentyfourteen_posted_on();
    
    		if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) :
    	?>
    	<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyfourteen' ), __( '1 Comment', 'twentyfourteen' ), __( '% Comments', 'twentyfourteen' ) ); ?></span>
    	<?php
    		endif;
    
    		edit_post_link( __( 'Edit', 'twentyfourteen' ), '<span class="edit-link">', '</span>' );
    	?>
    
    	<?php echo do_shortcode('[rt_reading_time label="Reading Time:" postfix="minutes"]'); ?>
    </div><!-- .entry-meta -->

    That will return a <span> elements containing the reading time wherever you call it in your theme. Then you can wrap it within any elements you want like <div class="your-own-div"><?php echo do_shortcode('[rt_reading_time label="Reading Time:" postfix="minutes"]'); ?></div>.

    Within Twenty Fourteen that will look like this.

    Hope that helps! Let me know if you have any more questions.

    Plugin Author Jason Yingling

    (@yingling017)

    Hope this is working out for you. I’m going to mark this topic as resolved. If you have any further questions let me know.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Where to put do_shortcode’ is closed to new replies.