Display category name on featured image in wordpress excerpt
use get_the_category() <?php foreach((get_the_category()) as $category) { echo $category->cat_name . ‘ ‘; } ?> Note: It will return a list of categories if there are more than one category
use get_the_category() <?php foreach((get_the_category()) as $category) { echo $category->cat_name . ‘ ‘; } ?> Note: It will return a list of categories if there are more than one category
If you are talking about excerpt set manually in the excerpt field of post then you can use following code in the functions.php file of your child theme or plugin to display default excerpt if no excerpt it set. function display_default_excerpt( $excerpt ) { if ( has_excerpt() ) { return $excerpt; } else { return … Read more
get_the_excerpt function has issues using it with wp_get_recent_posts so instead of get_the_excerpt function use wp_trim_excerpt function in your code as displayed below. <?php $args = array( ‘numberposts’ => ‘3’ ); $recent_posts = wp_get_recent_posts( $args ); foreach( $recent_posts as $recent ){ ?> <div class=”wpb_column vc_column_container vc_col-sm-4″> <div class=”wpb_wrapper”> <div class=”wpb_text_column wpb_content_element wpb_animate_when_almost_visible wpb_left-to-right wpb_start_animation”> <div class=”wpb_wrapper”> … Read more
If you type your poets like this in the editor and separate them by new lines: This is a phrase This is another phrase Then you can divide them by new line, and then return them to the front-end. You can do this by using the get_the_excerpt filter. This goes in your theme’s functions.php file: … Read more
The way to retreive some meta data is knowing the name of the custom field, for my example I will use: listing, property and address; normally this can be done after while (have_posts()) : the_post(); $listing = get_post_meta($post->ID, ‘listing’, true); $property = get_post_meta($post->ID, ‘property’, true); $address = get_post_meta($post->ID, ‘address’, true); then you can print the … Read more
Does the_excerpt() work if you remove the custom functions you have? Firstly, for sanities sake to make sure the excerpt has a value, could you try replacing your current excerpt call with this? <?php echo get_post_field(‘post_excerpt’, $post->ID); ?> If it does work then the problem is most likely related to your custom functions.
If you want to always return post content when trying to get post excerpt, you can use get_the_excerpt filter like this. add_filter( ‘get_the_excerpt’, ‘wp256_use_content_as_excerpt’, 10, 2 ); function wp256_use_content_as_excerpt( $excerpt, $post ) { return wp_strip_all_tags( $post->post_content ); }
You are using the wrong filter. Depending on how your theme is built, there may be two solutions. If the theme uses the wp_trim_excerpt function, the excerpt_more filter inside that function will only be called if there is no excerpt passed to that function. At the end of that function there still is the wp_trim_excerpt … Read more
After Lots of Research and Testing, I got the answer. the_excerpt and other custom function are not working because there is no any content tag On feed xml format. You just need to add this code instead of the_excerpt <p><?php echo esc_html( $item->get_description() ); ?></p> More you can Visit https://wordpress.org/support/topic-tag/get_description/ The Full code may you … Read more
Using the “more” tag does not create an excerpt. It simply creates a “Read More” link when displaying the_content() on index pages. Excerpts are created/displayed as follows: To display an excerpt, your template file needs to call “the_excerpt()” rather than “the_content()”. Note: you use the equivalent $post->post_excerpt, which should also work just fine. The “the_excerpt()” … Read more