If you have only one template it’s fine to do something like:
echo '<p class="whatever">' . get_the_excerpt() . '</p>';
However, if you have multiple templates and want to control the classes centrally, you can make a filter on get_the_excerpt
as follows (but yeah, that would be in functions.php
):
add_filter ('get_the_excerpt','wpse240352_filter_excerpt');
function wpse240352_filter_excerpt ($post_excerpt) {
$post_excerpt="<p class="whatever">" . $post_excerpt . '</p>';
return $post_excerpt;
}
You would then simply have echo get_the_excerpt();
in your template files.
Related Posts:
- functions.php inject inline css
- How do I create a new WP admin color scheme?
- Logout/login redirect CSS issue
- Modify CSS via Theme Control Panel
- Add attribute to link tag that’s generated through wp_register_style?
- How to customize search result page title?
- How to add CSS style sheet dynamically in wordpress
- Simple/basic use of get_current_screen
- Is it possible to be more page/post specific with admin_enqueue_script?
- Child Theme Not Overriding Parent Theme
- Can I use require() function in a template file?
- How to set global variables in template page?
- Enqueue styles after a plugin
- Dequeue script in template isn’t working
- Help to resolve Syntax error, unexpected ‘endwhile’ (T_ENDWHILE) [closed]
- Adjust which tempalte a page uses with a function?
- How to change menu icon which is overriden (i.e. by WooCommerce) [closed]
- How to add background image control to page admin controls?
- Make “sidebar template” the default template for new pages
- Retrieve post modified date for specific post by post ID
- Attach parent category template to all subcategories
- How to remove howdy dropdown menu content
- How to include local menu based on page id?
- Multiple CSS body classes to specific page I.D.’s – is this possible?
- How to create function from code?
- Display Password Protected external RSS in wordpress template
- How to extract the variables out from “add_shortcode” function?
- Default Gallery Edit/Template Editable?
- Selective Product Category for Carousel
- How to change login labels
- Enqueue Style Only On Certain Pages Not Working
- Why does the ‘wp_nav_menu’ function work only until a menu is created?
- Modify a function without editing template
- Retrieve tags data in post body
- change the url paths in the stylesheet dynamically
- Please Explain the Importing Process of Multiple Stylesheets for Child Themes
- Functions For Calling Specific Elements
- Full page template function
- different style sheet for just one page template
- wordpress use single ajax in place of multiple ajax requests in a smarter way
- Add Element as a Filter to the_content
- Custom styles.css sheet for visual editor
- Is my code correct to enqueue CSS on a specific page?
- Need print logo without any ID & class
- Not all CSS elements transferring via parent to child?
- Define PHP variable from a seperate API if statement
- Split Media Queries in different files!
- attachment page template? only show attachments for current post?
- How to include any template using Shortcode fuction?
- Image loading function not working on archive.php template
- How to insert class in each list of categories?
- Parent theme styles overriding child theme CSS [closed]
- I can’t add CSS with functions.php
- Theme JS is available but theme CSS isn’t
- Proper Way to Load stylesheet on Condition
- This code works, but the way I integrated it is breaking the media uploader. How can I integrate it properly?
- Specify multiple categories for custom post template – FATAL ERROR
- How to make a new function that includes a template
- remove/hide wp-editor
- Page Template Won’t Load Correct CSS File
- Show admin page, only if function is being used
- Overwriting TwentyTwelve template file with child theme template, but lower in the hierarchy
- Render page with specific id from functions.php
- the_date() and the_time() functions display actual date an time instead of published date and time
- Changing the HTML of notices in WooCommerce [closed]
- Can’t load assets
- How to reference different css (bootstrap) stylesheets for the header and body of a page?
- Can we have conditional CSS styling?
- CSS style and app.js not loading
- Post content overflows on my mobile phone
- Stylesheet does not load despite functions.php
- function class doesnt work
- Help using ShortCodes to style whole chunks of the post
- how to remove a tag in the_category function
- How to add styles in existing function?
- Adding a class to the body of an inactive site using multisite
- Conditionally apply css for a specific template part
- More than one search results page template for two searches on site
- Child Theme not loading multiple stylesheets
- Correct way of Enqueue self hosted fonts in sass project
- How to automatically add custom classes to headings in content area
- Newest comments first not working
- Retrieve a custom form field modified by a filter
- us states dropdown function and echo in theme template files
- How to pass a variable from a template page to the child theme functions.php
- Function the_content
- Random text changing to weird icons in both admin & front end
- Allow the access over wp-login.php
- Functions.php in child theme that loads CSS file breaks website
- functions.php / replacing div’s with new ones?
- Should I use `get_stylesheet_uri()` or `get_template_directory_uri()` when calling my CSS Stylesheet?
- How can i hide content if not friend in Buddypress? [closed]
- Image width issue in IE [closed]
- How do I make my child theme’s CSS update when I save it?
- Which template file to edit to edit homepage in Mystile [closed]
- Make a PHP file with a function
- Creating mixture of shortcodes to use in the visual/text editor
- Why don’t ‘wp_nav_menu’ CSS classes work until a menu is created?
- My website is generating weired url parameters of paginated pages
- How to store page-{id}.php templates in custom folder