Hi, Thanks for looking.
I’m trying to pull part of a page into my sidebar, throughout my site. I started using query_posts, but this didn’t work, because it changes the main query for the page, so my main post would come up as the sidebar page.
I’ve found a solution in using get_page, but I’m wondering if there’s a better way to do it- specifically whether there’s a way to obtain the page by title rather than id…
Here’s the code I’m using:
<?php $page_id = 2; $page_data = get_page( $page_id ); $title = $page_data->post_title; // Get title $content = $page_data->post_content; // Get Content echo $title; echo $content; ?>
Any help would be much appreciated..
- The topic ‘Using get_page- is there a better way?’ is closed to new replies.