WordPress.org

Ready to get started?Download WordPress

Forums

Occasionally fail to append DIV at the end of the post with filter the_content (3 posts)

  1. Engageya
    Member
    Posted 1 year ago #

    Hi,
    I am trying to append a div at the end of the content.
    I succeed to do so in some wordpress blogs, but others simply do not add the div.
    I tested and saw that the my_add_widget function is being invoked in all blogs - but the div is just not appended in some cases.

    Example of blog that do succeed to append the div: http://www.mixedwaves.com/
    Example of blog that fails to append the div:
    http://www.motorbikenews.co.uk/video-samsung-honda-meet-the-raf/

    Code:

    function my_add_widget($content)
    {
    $linkToPost = get_permalink($post->ID);
    $content .= '<div id="ewidget_'. $post->ID .'"></div>';
    return $content;
    }

    add_filter('the_content', 'my_add_widget');

    Any idea why is that?

    Best,
    Anat.

  2. Engageya
    Member
    Posted 1 year ago #

    Another examples of blogs that do not append the div from the_content

    [irrelevant links moderated]

  3. ianhaycox
    Member
    Posted 1 year ago #

    It might help if $post was defined.

    Set WP_DEBUG to true in wp-config.php to catch errors like this.

Topic Closed

This topic has been closed to new replies.

About this Topic