phrozen755
Member
Posted 11 months 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
phrozen755
Member
Posted 11 months ago #
phrozen755
Member
Posted 11 months ago #
phrozen755
Member
Posted 11 months ago #
phrozen755
Member
Posted 11 months 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');
?>
phrozen755
Member
Posted 11 months 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!
benjiw
Member
Posted 2 months ago #
Is it possible to put PHP in the output? I keep getting parse errors when I try...