Forums

the_content not working ?? (4 posts)

  1. Massyn
    Member
    Posted 1 year ago #

    Hi team, I'm playing with plugins, and I have this perculiour problem. My plugin code (below) simply adds some text after the post (in this example, it adds code to the Digg button).

    The plugin works on my site (www.massyn.net) but it does not work on my other (www.podoza.net).

    My question is - what would cause a filter not to fire? Is there a way I can troubleshoot this? I'm working on another filter that will do something similar on the_content, but the same deal -- no go... Funny enough though, on the About page the plugin fires, but not on the posts..

    Any ideas?? Thanks!

    add_filter ('the_content', 'digger_main');
    
    function digger_main ($text)
    {
            return $text . ' <script type="text/javascript">digg_url = "' . get_permalink() . '"; digg_title = "' . get_the_title() .'";</script><script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script> ';
    
    }
  2. terriann
    Member
    Posted 12 months ago #

    I am having a similar problem - but it seems to be for only some of my testers.
    This applies to both add_filter and add_action (I've tested both.)

    The admin menu is displaying properly but the filter_content() isn't working:

    class Foo{
    function Foo(){
    add_action('the_content', array(&$this, 'filter_content'), 101);
    add_action('admin_menu', array(&$this, 'add_options_page'));
    }
    function filter_content($text){
    return $text . '<script type="text/javascript">...</script>';
    }
    }

    Ideas? Did you ever find a solution? This also seems to be related to another unanswered post as well.

  3. iridiax
    Member
    Posted 12 months ago #

    the_content must be within The Loop for it to work.

  4. terriann
    Member
    Posted 12 months ago #

    The content is displaying within the loop, the problem is that the hook appending the script isn't appending the script to the content that is displayed.

    So my hook should append <script type="text/javascript">...</script> to my content 'hello world'.

    When I call the_content 'hello world' displays but the script tag does not.

    Does that make more sense?

Topic Closed

This topic has been closed to new replies.

About this Topic