WordPress.org

Ready to get started?Download WordPress

Forums

Inserting widgets within the_content (8 posts)

  1. phrozen755
    Member
    Posted 5 years ago #

    I tried searching around, if someone finds anything related to this please let me know.

    I'm inquiring about inserting code within the the_content in my template's single.php file.

    An example of what I'm talking about could be found on news websites, such as the washington posts:

    http://www.washingtonpost.com/wp-dyn/content/article/2008/12/09/AR2008120903055.html?hpid=topnews

    Any ideas? Thanks so much!

    ~Brian

  2. phrozen755
    Member
    Posted 5 years ago #

    no bites eh?

  3. phrozen755
    Member
    Posted 5 years ago #

    bump!

  4. phrozen755
    Member
    Posted 5 years ago #

    bump

  5. phrozen755
    Member
    Posted 5 years ago #

    bump :(

  6. chaoskaizer
    Member
    Posted 5 years ago #

    I'm inquiring about inserting code within the the_content in my template's single.php file.

    add it inside your template's functions.php.

    <?php // example
    function my_single_content_filter($content)
    { global $wp_query;
    
    	if (!$wp_query->is_single) return $content;
    
    	$output = PHP_EOL;
    	$output .= '<div style="float:right;width:210px">';
    	$output .= '<h3>random</h3>';
    	$output .= '<p>Thanks for all the fish.</p>';
            $output .= '<p><a href="#">links</a> ... </p>';
    	$output .= '</div>';
    
    	return $output.$content;
    }
    
    add_action('the_content','my_single_content_filter');
    ?>
  7. phrozen755
    Member
    Posted 5 years ago #

    That works great! But how do you get that content in the middle of the post, vertically, not horizontally?

    I think we're on to something :)

    Thanks for the reply!

  8. benjiw
    Member
    Posted 4 years ago #

    Is it possible to put PHP in the output? I keep getting parse errors when I try...

Topic Closed

This topic has been closed to new replies.

About this Topic