- This topic is empty.
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hi all,
I’m struggling with an issue about the excerpt. What i’ve got, is the following.
I’ve got an id of a page. And i want that specific page to be displayed on a particular place. But i don’t want to show the full content of the post. I know what you’re thinking, use the_excerpt!!! But that won’t work in this case, so in my search i found the function wp_trim_excerpt(), and when you put some text into this function, it will give an excerpt of that text.
Well that’s what the reference guide of WP says, but i don’t get the excerpt of the page, but the whole content.. Probably i’m using it one the wrong way. So, can someone give me a hand?
This is the code:
/* Get front-end block's */
function yandt_content_block( $position ) {
global $wpdb;
$content = $wpdb->get_row( "SELECT * FROM wp_yandt_frontcontent_content
WHERE
name = '" . mysql_real_escape_string( $position ) . "'" );
// Get the page by ID
$ID = $content->content_id;
$page = get_page( $ID );
// Check the position
$extraClass = '';
if( $position == 'Midden' ) {
$extraClass = 'middle-one';
}
// Build the block
echo '
' . $page->post_title . '
';
// Check for a thumbnail
if( has_post_thumbnail( $ID ) ):
echo get_the_post_thumbnail( $ID );
endif;
// Show the excerpt of this page
echo wp_trim_excerpt($page->post_content);
echo 'post_title . '" class="read-more">Lees verder
';
}