$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>How to add code in the content area in a Wordpress theme?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

How to add code in the content area in a Wordpress theme?

matteradmin9PV0评论

I basically want to add an embedded form at the end of every blog post just below the main content area (I tried adding in the footer but it gets skipped due to showing up at the very bottom of the page). Where exactly do I put the code in the editor?

I basically want to add an embedded form at the end of every blog post just below the main content area (I tried adding in the footer but it gets skipped due to showing up at the very bottom of the page). Where exactly do I put the code in the editor?

Share Improve this question asked Jun 6, 2018 at 21:34 Uday SarojUday Saroj 111 bronze badge
Add a comment  | 

2 Answers 2

Reset to default 1

If you want to modify the content before it is output to the screen, use the_content filter:

add_filter( 'the_content', 'change_the_content' )
function change_the_content($content) {
   $content = $content . "your additional content";
   return $content;
}

See docs here: https://codex.wordpress/Plugin_API/Filter_Reference/the_content .

You don't, if you want to embed something in a post, you have 2 options:

  • oembed: Great for stuff like youtube, and other things, think of embeds, think of things that can be represented as URLs, e.g. copy paste a youtube URL on to a blank line and it turns into a youtube player
  • shortcodes: This is how you run PHP code and insert HTML inside a post
  • filters: You can append the code via the_content filter to your posts when they're rendered. This allows you to add things without modifying the post content

Anything that will let you copy paste a form as is into a post edit screen is going to be a security problem, dramatically increasing the chances of your site becoming hackable

Post a comment

comment list (0)

  1. No comments so far