get page content by using page slug


$page_slug ='video';
$page_data = get_page_by_path($page_slug);
$page_id = $page_data->ID;
echo '<h2>' . $page_data->post_title . '</h2>';
echo apply_filters('the_content', $page_data->post_content);
Advertisements

3 thoughts on “get page content by using page slug”

  1. Hi.

    echo apply_filters(‘the_content’, $page_data->post_content);

    This does not seem to work.
    Any idea why?

    Thanks

    1. Hi waaab crew, It will work if you supply correct slug to this function get_page_by_path().
      for example if url is http://www.example.com/test-slug then your code will be as follows

      $page_slug ='test-slug';
      $page_data = get_page_by_path($page_slug);
      

      Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s