WordPress.org

Ready to get started?Download WordPress

Forums

Google accesses post before it has been processed by plugins? (4 posts)

  1. asandler
    Member
    Posted 5 years ago #

    I've written a wordpress plug-in that automatically generates table of contents for my posts. It generates the TOC only if it sees [[toc]] tag in the post contents. When it sees the tag, it generates the TOC and puts it instead of the tag.

    I ran into this problem and I was wondering how is it possible. My plug-in processes all posts and pages and doesn't leave the [[toc]] tag in any case I am aware of. Yet, somehow, google managed to cache post contents containing the tag.

    Take this search for example: http://www.google.com/search?hl=en&q=tcpdump+for+dummies&cts=1245875926331&aq=f&oq=&aqi=g%3Ap1
    tcpdump for dummies is the name of an article on my blog. Note that the article excerpt google presents contains [[notoc]] and [[toc]]. Both are tags that my plug-in removes - you can see it in the original article: http://www.alexonlinux.com/tcpdump-for-dummies

    In the plug-in, I use
    add_filter('the_content', 'smart_toc_filter', 6);
    to register the plug-in. This means that my plug-in should process all posts under any conditions, isn't it?

  2. adamh
    Member
    Posted 5 years ago #

    If you're putting the code into the post, you should be using the shortcode api - the benefit of this is that it does all the regex parsing for you to replace [toc] with the plugin output.

    http://codex.wordpress.org/Shortcode_API

    It wouldn't be too difficult - let me know if you need more help.

    Adam

  3. asandler
    Member
    Posted 5 years ago #

    Adam, Thanks for your response.

    To be honest shortcode api doesn't suite my plug-in very well. It is more suitable for cases when you need to do some processing to some small piece of code. For that to work, you can leave the right shortcode api tag in the post contents and the api will replace it with something meaningful. My plug-in does something a little more complicated.

    It replaces the toc tag with table of contents, but also, it searches for all html heading tags in the post and puts an anchor link around them. When the plug-in generates the toc, it links to the anchors in the toc. It seems to me that with shortcode api it will be much more difficult to do.

    Something tells me that using shortcode api instead of the filter, may fix the problem with google, but before I go on and rewrite the entire plug-in, I want to get to the root of the problem.
    Do you have any idea what it might be?

  4. asandler
    Member
    Posted 5 years ago #

    Anyone?

Topic Closed

This topic has been closed to new replies.

About this Topic