Here is the code to display the excerpt of the current requested page in WordPress. This code works outside loop also. Excerpts are usually displayed in description meta tags.
<?php
if(is_single() || is_page())
{
global $wp_query;
$id = $wp_query->post->ID;
$the_post = get_post($id);
$the_excerpt = $the_post->post_content;
$shortcode_pattern = get_shortcode_regex();
$the_excerpt = preg_replace('/' . $shortcode_pattern . '/', '', $the_excerpt);
$the_excerpt = strip_tags($the_excerpt);
echo esc_attr(substr( $the_excerpt, 0, 200));
}
else if(is_home() || is_front_page())
{
echo "QNimate provides tutorials on WordPress, Hybrid Mobile Development, Web Development and Much More";
}
else if(is_category())
{
$name = single_cat_title('', false);
echo "Learn about " . $name;
}
else if(is_tag())
{
$name = single_tag_title('', false);
echo "Learn about " . $name;
}
else if(is_date())
{
$date = single_month_title(' ', false);
echo "Displaying posts of ". $date;
}
if(is_single() || is_page())
{
global $wp_query;
$id = $wp_query->post->ID;
$the_post = get_post($id);
$the_excerpt = $the_post->post_content;
$shortcode_pattern = get_shortcode_regex();
$the_excerpt = preg_replace('/' . $shortcode_pattern . '/', '', $the_excerpt);
$the_excerpt = strip_tags($the_excerpt);
echo esc_attr(substr( $the_excerpt, 0, 200));
}
else if(is_home() || is_front_page())
{
echo "QNimate provides tutorials on WordPress, Hybrid Mobile Development, Web Development and Much More";
}
else if(is_category())
{
$name = single_cat_title('', false);
echo "Learn about " . $name;
}
else if(is_tag())
{
$name = single_tag_title('', false);
echo "Learn about " . $name;
}
else if(is_date())
{
$date = single_month_title(' ', false);
echo "Displaying posts of ". $date;
}
For home, category, tag and date pages you need to define the expert explicitly. For posts and pages the excerpt is retrieved from the content.