Title: Replacing Page Content
Last modified: August 21, 2016

---

# Replacing Page Content

 *  [mikecd](https://wordpress.org/support/users/mikecd/)
 * (@mikecd)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/replacing-page-content/)
 * So I’d like to be able to put a shortcode at the begging of a page. Then if certain
   conditions aren’t met only display what’s generated by the shortcode, not any
   of the other content in the page.
 * Simply put, I’d like to be able to do something like this:
 *     ```
       add_shortcode('myshortcode','myfunction' );
   
       function myfunction( $atts ) {
          if ( somestuff ) {
             Display the page's content. Short code basically does nothing.
          } else {
             Replace all of the page's content. Completely replace the content with php code here.
       }
       ```
   
 * So far everything I’ve tried has failed.

The topic ‘Replacing Page Content’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [mikecd](https://wordpress.org/support/users/mikecd/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/replacing-page-content/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
