Posted By

manocreative on 01/17/11


Tagged

wordpress


Versions (?)

Wordpress Content From Separate Page Without ID


 / Published in: PHP
 

URL: http://mpme.tumblr.com/post/2660646773/wordpress-get-content-from-separate-page

Working with Wordpress 3.04, pretty URLs in permalink settings must be enabled.

Allows you to get content from a different wordpress page. If you liked this, please like my facebook page http://bit.ly/manocreativeinc

  1. <?php
  2.  
  3. //PERFORMS MYSQL QUERY TO GET THE POST ID
  4. //note: 'about' is the name of the page, you can use any named, ex: 'web services'
  5. $about_page_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = 'about'");
  6.  
  7. $post_id = get_post($about_id);
  8. $content = $post_id->post_content;
  9.  
  10. //applies wordpress filter (includes <p> tags)
  11. $content = apply_filters('the_content', $content);
  12.  
  13. $content = str_replace(']]>', ']]>', $content);
  14.  
  15. echo $content;
  16. ?>

Report this snippet  

You need to login to post a comment.