WordPress.org

Support

Support » Themes and Templates » Inserting widgets within the_content

Inserting widgets within the_content

Viewing 7 replies - 1 through 7 (of 7 total)
  • no bites eh?

    bump!

    bump

    bump 🙁

    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');
    ?>

    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!

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Inserting widgets within the_content’ is closed to new replies.
Skip to toolbar