I want to check if excerpt is not empty, then echo the excerpt link, if not the echo permalink, like this:
if(the_excerpt()!='') echo the_excerpt(); else echo get_permalink()
but how can I check if the excerpt field is empty without using the content when empty?
Any help will be appreciated.
I want to check if excerpt is not empty, then echo the excerpt link, if not the echo permalink, like this:
if(the_excerpt()!='') echo the_excerpt(); else echo get_permalink()
but how can I check if the excerpt field is empty without using the content when empty?
Any help will be appreciated.
Try this one , ..
$ID = get_the_ID();
$page_data = get_page( $ID );
$excerp = strip_tags($page_data->post_excerpt);
if ( !empty( $excerp ) ) :
the_excerpt();
else :
echo get_permalink()
endif;
You can simply check excerpt via
if(has_excerpt()){
//do your stuff
}else{
//do your stuff
}
if(get_the_content()!='') echo get_permalink(); else echo the_excerpt();
– rakela Commented Oct 15, 2014 at 11:54echo
forthe_excerpt()
. – birgire Commented Oct 15, 2014 at 12:49