Forums

Custom code added to a wordpress loop doesn't get response (4 posts)

  1. Ahsaniqbalkmc
    Member
    Posted 4 months ago #

    I don't know whether I have interpreted my problem correctly in the topic title but I am sure I will be able to explain it here.
    I am trying to add "table of contents" to my pages. For this purpose, I have decided to use the plugin "md table of contents generator". It is a nice little plugin and is easy to use. The only problem I am having is that for the code to appear in the pages, I need to add "[toc]" to the page. It is very difficult for me to go through all the 500 pages of my website and add this code to each of them separately. I would have done that but editing it in the future will also be difficult so I need a better solution.
    I am trying to add the it to the wordpress loop but there the plugin doesn't response to it. It appears exactly the same on the page. I mean, instead of the div containing the table of content, I get the "[toc]" on my final page result. How can I get this to work?
    Is this possible that I extract all the code from the plugin and put it directly into the wordpress loop? Please help me on this?

  2. alchymyth
    The Sweeper
    Posted 4 months ago #

    I am trying to add the it to the wordpress loop

    whare exactly?

    can you paste the full code into a http://pastebin.com/ and post the link to it here?

    instead of the div containing the table of content, I get the "[toc]" on my final page result.

    please post a link to your site to illustrate the problem.

  3. Ahsaniqbalkmc
    Member
    Posted 4 months ago #

    Here is the link to the code of the plugin:
    http://pastebin.com/HimkZF69
    And here is the link to my website's page where I have added the table of contents custom tags:
    http://www.techno99.com/search-engine-optimization-tools/

    When you go to the page, you would see two table of contents displayed. These, I have manually added to the content of the page. By content of the page, I mean the actual post itself.
    The "[toc]" displayed at the top is the code I added to the wordpress loop. The plugin failed to respond to it.
    It is added as shown below:

    <?php get_header(); ?>
            <div id="content">
                <div id="postarea">
    		    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
            <div class="postcontent">
                <div class="postcontent_in">
    
                    <div class="post">
    		    <h2><?php the_title(); ?></h2>
    
                        <div class="post">
    
    <strong><p>[toc]</p></strong>
    
                            <?php the_content(__('Read more'));?>
                        </div>
    
                    <div class="clear"></div>
                    </div>
                    </div>
                </div>
    
                <?php endwhile; else: ?>

    As you can see in the code above, I have added <p>[toc]</p> because when you see the coding of the plugin, you would find that it searches for the string <p>[toc]</p> and not simply [toc]. But this also doesn't work.

  4. Ahsaniqbalkmc
    Member
    Posted 4 months ago #

    Sorry!
    I added the
    <strong></strong> around the <p>[toc]</p> to make it bold only in this post. It is not present in the actual content of my page so please take it out of the consideration.

Reply

You must log in to post.

About this Topic