Title: Php script in post&#8230;?
Last modified: August 19, 2016

---

# Php script in post…?

 *  [cje](https://wordpress.org/support/users/cje/)
 * (@cje)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/php-script-in-post/)
 * I would like to add a script to my blog, but w/o change the template codex (which
   will put me in trouble when updating).
 * Is it possible -some how – to put this code directly into the post?
    ([http://codex.wordpress.org/Template_Tags/get_posts](http://codex.wordpress.org/Template_Tags/get_posts))
 * Thanks for any suggestions

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [figaro](https://wordpress.org/support/users/figaro/)
 * (@figaro)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/php-script-in-post/#post-1069590)
 * You can put php in a post by using a plugin like this one:
 * [http://wordpress.org/extend/plugins/php-execution-plugin/](http://wordpress.org/extend/plugins/php-execution-plugin/)
 *  Thread Starter [cje](https://wordpress.org/support/users/cje/)
 * (@cje)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/php-script-in-post/#post-1069758)
 * thanks a lot!
    btw, do you know php code? I’ve tried to use the bellow code to
   display a random post, from my category “category | test”, in a static page, 
   on the front page but it returns a fatal error
 * Fatal error: Allowed memory size of 52428800 bytes exhausted (tried to allocate
   35 bytes) in /var/www/testserver/test/wp-includes/plugin.php on line 385
 * <?php
    $rand_posts = get_posts(‘numberposts=1&offset=1& category_name=category
   | test&orderby=rand’); foreach( $rand_posts as $post ) : ?> <div class=”body”
   > <?php the_excerpt(); ?></div> <?php endforeach; ?>
 * Do you know what’s wrong?
    Thanks for any suggestions!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Php script in post…?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [cje](https://wordpress.org/support/users/cje/)
 * Last activity: [17 years, 1 month ago](https://wordpress.org/support/topic/php-script-in-post/#post-1069758)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
