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:
- How to load scripts/styles specific for a page
- How to redirect to post if search results only returns one post
- functions.php inject inline css
- How to override admin-bar style
- How do I create a new WP admin color scheme?
- Logout/login redirect CSS issue
- wp_get_attachment_image returns different image size
- Passing variables to templates (alternatives to globalizing variables)
- Load post with a different template?
- 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?
- TinyMCE custom stylesheets for different post types
- How to fix a theme with page.php Default Template that accidentally deleted?
- WordPress Change Post Templates,but not drop down, but Image selection
- Remove “says” from comments
- 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?
- Using locate-template & shortcodes doesn’t appear to work
- Child Theme Not Overriding Parent Theme
- CSS stylesheet not loading
- Can I use require() function in a template file?
- How to set global variables in template page?
- Why isn’t is_page_template() adding a body class?
- Enqueue styles after a plugin
- Dequeue script in template isn’t working
- Query children and parent title
- 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?
- Register and enqueue style.css custom theme
- 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?
- How to enable template page only for a post id page
- 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
- Child Theme files – what is needed?
- How do I add Bootstrap and LESS to my migrated WordPress site?
- How to Display Frontend CSS for Administrator only
- WordPress Menuing Question :focus
- 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
- Change CSS for logged in users
- How to stop wordpress from injecting hard-coded style into image attachments with captions
- 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?
- I have problems with loading javascripts
- header_image() with CSS
- Pass variable from action back to template
- 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!
- Some questions about how proper add 2 CSS file in a WordPress theme?
- Best way to handle lack of titles in microblogging
- problem loading stylesheets to wp_head dynamically
- attachment page template? only show attachments for current post?
- Run a jquery script on on a certain template page
- How to include any template using Shortcode fuction?
- Image loading function not working on archive.php template
- Add a field into a shortcode of an extension
- 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
- Default Nav Highlight
- Custom styles in Tiny MCE with an external CSS file
- Using functions.php to include code that’s processed inline
- why can’t i add front.css to my frontpage.php
- How to make a new function that includes a template
- get_template_directory_uri() links to child theme not parent
- remove/hide wp-editor
- Getting out side of wp root folder from function.php using absolute path
- Page Template Won’t Load Correct CSS File
- current_page_item is missing inside wp_nav_menu
- wp_head not injecting css
- How to store page-{id}.php templates in custom folder
- Add custom css to specific user