#25191 closed defect (bug) (invalid)
Regarding Access of excerpt of Page
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
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:
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)
#2
@
11 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
@
11 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; wp_reset_postdata();
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 ); the_excerpt(); wp_reset_postdata();
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.
What do you mean by deactivation?
get_page()
was softly deprecated in favor ofget_post()
in 3.5 ([21598]), but it's still a working alias ofget_post()
since 3.0 ([15188]).I don't see an issue with the page title or excerpt in the links above, could you elaborate?