Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#25191 closed defect (bug) (invalid)

Regarding Access of excerpt of Page

Reported by: alpesh1988 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:


Hello, Recently I was building a website where I needed to select a page and then to show page excerpt for that particular page.

Following are the links:

  1. http://the-equities-room.rtcamp.net/
  2. http://the-equities-room.rtcamp.net/about-us/

There is a homepage in link-1. It has title of 'ABOUT THE EQUITIES ROOM' besides to 'Recent Posts' title. It is not shown as it is in given links due to deactivation of 'get_page()' function in wordpress 3.6. There is no other way i found out for the same. Hence, marking this as a defect.

Change History (5)

#1 @SergeyBiryukov
7 years ago

  • Component changed from Accessibility to General
  • Keywords reporter-feedback added

It is not shown as it is in given links due to deactivation of 'get_page()' function in wordpress 3.6.

What do you mean by deactivation? get_page() was softly deprecated in favor of get_post() in 3.5 ([21598]), but it's still a working alias of get_post() since 3.0 ([15188]).

I don't see an issue with the page title or excerpt in the links above, could you elaborate?

#2 @alpesh1988
7 years ago

Deactivation means 'deprecated' what i meant for. I explain you the scenario.

The need is to show a excerpt for a page. To do so, I have a custom widget in which from dropdown menu, I can select a one page out of the pages i have built in site. For example, I selected 'About us' Page. I get the page id using get_page(). After that I am not able to show the excerpt using the key [post_excerpt]. It does not print anything. I guess It is because page can not have excerpt. so the styling for 'about us' page in given link1 is not same as in link2.

Currently I am getting content using wp_html_excerpt() with word limit.

so the question is Why [post_excerpt] does not work in get_page() ?

#3 @SergeyBiryukov
7 years ago

Pages indeed don't have an Excerpt meta box by default, but you can add it using add_post_type_support() in theme's functions.php file::

function my_custom_init() {
	add_post_type_support( 'page', 'excerpt' );
add_action( 'init', 'my_custom_init' );

This would only work if the page has the post_excerpt database field actually filled in via the meta box.

$page_id = 2; // Sample Page
$post = get_post( $page_id );

echo $post->post_excerpt;


This, however, works even if post_excerpt field is empty, by applying wp_trim_excerpt() function to the content:

$page_id = 2; // Sample Page
$post = get_post( $page_id );
setup_postdata( $post );



This behaviour is the same for posts and pages, it did not change in 3.6 and has nothing to do with get_page() soft deprecation in 3.5. This sounds like a support issue, I don't see a bug here.

Last edited 7 years ago by SergeyBiryukov (previous) (diff)

#4 @alpesh1988
7 years ago

  • Status changed from new to closed

That is an alternative I knew. But I got some more clarification regarding [post_excerpt] which cleared my doubt.

Thanks sergey...

#5 @SergeyBiryukov
7 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
Note: See TracTickets for help on using tickets.