WordPress.org

Ready to get started?Download WordPress

Forums

Modifying plugin to be displayed on the homepage (1 post)

  1. StompingBrokenGlass
    Member
    Posted 2 years ago #

    It's my second day looking at this problem, I guess there is an obvious answer for this, but I guess I couldn't find it.

    Here it goes,
    I have a plugin that displays a floating bar with social media icons on it, currently it's displayed only on posts by injecting some codes into the body using the following:

    <?php
    
    function adding_Floatbar($content) {
    	$barContent = add_Floatbar();
    if(!is_home()) {
    	$content = $barContent . $content;
    	return $content;
    }
    else { return $content; }
    }
    
    /*
    *  Adding the floatiung bar to the page, by attaching it to the_content filter
    */
    add_filter('the_content', 'adding_Floatbar');
    
    /*
    * Generating the floting bar, and it's content depending on the selected options.
    */
    
    function add_Floatbar() {
    if (is_single()) {
    // Other conditions and Injected HTML
    }
    ?>

    I tired to remove the condition at adding_Floatbar(), and modifying add_Floatbar() to

    function add_Floatbar() {
    if (is_single() || is_home()) {
    // Other conditions and Injected HTML
    }

    But it made it display several times, depending on the number of posts displayed on it.

    So, is there is a way to display it only once?
    And sorry in advance if it was posted before.

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 2 years ago by StompingBrokenGlass
  • This topic is not resolved
  • WordPress version: 3.2