0

I have a page called "About Us" with some static content. I want to display that static content on the home page. Would I need to do a custom query that returns the about page, or is there a better way?

$about_page = new WP_Query('p=7'); // is this basically it? 

Is there a better way to do this? A more dynamic way that would allow me to distribute this theme to others who don't have a specific ID for an About page.

EDIT:

Found this page on the Codex. It recommends using the get_page function.

  • There are so many ways to implement this. The best approach is entirely dependent on your specific use-case. Question: are you displaying the "About Us" page, or merely pulling its content into your site front page? – Chip Bennett Oct 19 '11 at 15:29
  • Pulling. here's the site: adultdatinghistory.com Left hand side, the section called "welcome to {site name}" is pulled. – 21zna9 Oct 21 '11 at 3:48
0

If you're using WP_Query, then assign that page a custom meta key 'home_content' with a value as 1. Then use WP_Query's custom field parameters to loop over it. If you can restrict the title as 'About' everywhere, use get_page_by_title, and if you can restrict the slug as 'about', use get_page_by_path. These methods will work dynamically.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.