Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress Post Excerpt Class

Tags:

wordpress

I'm customizing a Wordpress Theme and i have stucked in add a custom class to the "the_excerpt()".

I have searched on the web for this function, but nothing is specific to add a custom class.

Hm, i've tried the "get_the_excerpt", but this one doesn't work (returns nothing).

Anyone knows how to do this?

like image 654
reidark Avatar asked Aug 15 '14 03:08

reidark


People also ask

How do I get excerpt of post in WordPress?

An excerpt can be auto generated by a WordPress theme or by using the <! --more--> tag inside the post content. Another way to create excerpts for a WordPress post is by entering the summary of an article in Excerpt field on Post Edit screen. This field is not displayed in the post edit screen by default.

How do I set up auto excerpt in WordPress?

Log in to your WordPress admin panel. In the left column navigation, mouse over the “Plugins” link and click the “Add New” link. In the “Search plugins…” box, enter “Easy Custom Auto Excerpt.” Once you have located the plugin, click the “Install Now” button.

What is the excerpt function in the post format options?

Displays the excerpt of the current post after applying several filters to it including auto-p formatting which turns double line-breaks into HTML paragraphs. It uses get_the_excerpt() to first generate a trimmed-down version of the full post content should there not be an explicit excerpt for the post.


Video Answer


1 Answers

<?php echo  get_the_excerpt(); ?>

Shows the excerpt

<p class="your-class"><?php echo  get_the_excerpt(); ?></p> 

Shows the excerpt in a div with a class

like image 194
antonio83 Avatar answered Oct 07 '22 07:10

antonio83