Support » Plugin: Table of Contents Plus » Display TOC in a single.php page, it's possible?

  • I want to change the position of TOC from the default ones on the post content itself to a DIV inside a single.php. Inside a DIV I did this:

    [code]<?php echo do_shortcode('[toc label="Index by Title"]') ?>[/code]

    But is not working since nothing is displayed also I don’t know how to hide or change the default behavior, any advice?

    https://wordpress.org/plugins/table-of-contents-plus/

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

    (@reypm)

    This is how my code looks like:

    <?php get_header(); ?>
    <?php $thePostID = get_the_ID(); ?>
    
    <div id="content">
        <div class="legislacion-col-izq">
            <div class="CajaIzq">
                <div class="shortcodeToc">
                    <?php
                    $children = new WP_Query( array(
                        'post_parent'    => $thePostID,
                        'posts_per_page' => - 1    // get all children
                    ) );
                    while ( $children->have_posts() ) {
                        $children->the_post();
                        echo
                            '<h3>' . get_the_title() . '</h3>' .
                            '<ul>' . toc_get_index( get_the_content(),
                                get_permalink( $children->post->ID ) ) . '</ul>';
                    }
                    wp_reset_postdata();
                    ?>
                </div>
            </div>
        </div>
        <div class="legislacion-col-der">
            <div class="CajaContenido">
                <h1 class="titulo"><?php the_title(); ?></h1>
                <?php if ( have_posts() ) : ?>
                    <?php while ( have_posts() ) : the_post(); ?>
                        <?php $options = get_option( 'responsive_theme_options' ); ?>
                        <?php if ( $options['breadcrumb'] == 0 ): ?>
                            <?php echo responsive_breadcrumb_lists(); ?>
                        <?php endif; ?>
    
                        <div id="post-<?php the_ID(); ?>">
                            <div class="post-entry">
                                <?php the_content( __( 'Read more ›', 'responsive' ) ); ?>
                                <?php wp_link_pages( array(
                                    'before' => '<div class="pagination">' . __( 'Pages:',
                                            'responsive' ),
                                    'after'  => '</div>'
                                ) ); ?>
                            </div>
                            <!-- end of .post-entry -->
                            <?php if ( comments_open() ) : ?>
                                <div class="post-data">
                                    <?php the_tags( __( 'Tagged with:', 'responsive' ) . ' ', ', ', '<br />' ); ?>
                                    <?php the_category( __( 'Posted in %s', 'responsive' ) . ', ' ); ?>
                                </div><!-- end of .post-data -->
                            <?php endif; ?>
                            <div class="post-edit"><?php edit_post_link( __( 'Edit', 'responsive' ) ); ?></div>
                        </div><!-- end of #post-<?php the_ID(); ?> -->
                        <?php comments_template( '', true ); ?>
                    <?php endwhile; ?>
                    <?php if ( $wp_query->max_num_pages > 1 ) : ?>
                        <?php if ( function_exists( 'wp_paginate' ) ) {
                            wp_paginate();
                        } ?>
                    <?php endif; ?>
                <?php else : ?>
                    <h1 class="title-404"><?php _e( '404 — Fancy meeting you here!', 'responsive' ); ?></h1>
                    <p><?php _e( 'Don't panic, we'll get through this together. Let's explore our options here.',
                            'responsive' ); ?></p>
                    <h6><?php printf( __( 'You can return %s or search for the page you were looking for.', 'responsive' ),
                            sprintf( '<a href="%1$s" title="%2$s">%3$s</a>',
                                esc_url( get_home_url() ),
                                esc_attr__( 'Home', 'responsive' ),
                                esc_attr__( '&larr; Home', 'responsive' )
                            ) );
                        ?></h6>
                    <?php get_search_form(); ?>
                <?php endif; ?>
            </div>
            <!-- end of .CajaContenido -->
        </div>
        <!-- end of .legislacion-col-der -->
    </div><!-- end of #content -->
    <?php get_footer(); ?>

    But is not working since none index is displayed, what I’m doing wrong?

Viewing 1 replies (of 1 total)
  • The topic ‘Display TOC in a single.php page, it's possible?’ is closed to new replies.