You need to wrap it in an HTML element that has a class. Doing it with your code will require changes.
You can either do it outside the PHP, which will require changing where you open and close the PHP tags:
<?php } else { ?>
<span class="classname">
<?php esc_html_e('No results found','ThemeName'); ?>
</span>
<?php } ?>
You can do it inside the PHP by concatenating a string, which means you’ll need to use esc_html__()
instead of esc_html_e()
(which echoes the result, which you shouldn’t do in the middle of a concatenation):
<?php
} else {
echo '<span class="classname">' . esc_html__('No results found','ThemeName') . '</span>';
}
?>
Or use printf()
to put the string together, also using esc_html__()
:
<?php
} else {
printf( '<span class="classname">%s</span>', esc_html__( 'No results found', 'ThemeName' ) );
}
?>
Related Posts:
- WordPress loop specific thumbnail size
- Is it possible to use the featured image of a page as a css background without inlining?
- Displaying theme options in css
- Theme Options Page – User Updates Logo
- How to use my style.css file outside of wordpress subdomain?
- How to modify mobile nav menu text in theme
- jQuery accordion menu
- Displaying images outside the content
- Problem with displaying CSS Stylesheets – Am I adding them correctly in my wordpress child theme?
- How to print all the inline styles in the WP_Styles instance together with their keys?
- register dependency css and js inside a plugin class
- Fix hover images blink
- CSS loading as empty file in Custom Theme
- How to add Open/Close Toggle button into Twenty Fifteen theme for hiding left sidebar?
- Click to expand menu
- Relative post date in recent posts list
- Sidebar doesnt get updated?
- Load slideshow.css file only if Slideshow is checked / on
- Predefine Magazine Style Layouts
- How to determine if WP_DEBUG is enabled? [duplicate]
- Get author full name
- How to export/import theme customizer settings?
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- One button to change all settings in theme customizer?
- How to use copy() function and paste file in /wp-content/themes directory
- Need help on WordPress and php
- Multiple pages on one with different HTML
- How can I add a class to a single menu item?
- Show different Customizer Settings on Page-Tamplates
- wp_enqueue_style with style.php and WordPress functions
- I think emoji are killing my WordPress site… How can I debug?
- Minify HTML, CSS, JS with PHPWee?
- Am I not understanding plugins?
- Custom Logo URL | Help me print the URL of the custom logo I inserted into my theme
- Why is this Ajax not working?
- How do themes render caption texts in extended markup (e.g. “wp-caption” paragraphs)
- WordPress override bloginfo variable
- Shortcode content output but not in correct place
- max_input_vars: how many am I using?
- Add a custom stylesheet for BlackBerry
- How to load a template-part based on a url wildcard?
- Multiple WordPress Menus that will only display all pages
- Custom theme: Alternatives to long list of ‘include’ in functions.php
- How to show part of the_content?
- Is there CSS to expand the gallery limit on Index Pages?
- Hide categories that are not used in the post type
- Menu jumping when calling it via PHP
- Different post styles depending on category
- two columns of posts on homepage, one of them “favorites”
- Is there a way to conditionally check whether a WordPress post title is empty?
- Use WordPress function in php file
- Why in my theme I can’t see all the statics content under the posts?
- Styling the second sidebar
- Theme not calling Jquery properly
- How to add drag and drop functionalities to a div inside option panel
- Double Curly Brackets in Php
- Get post categories
- Add New Text Box To WordPress Twenty Seventeen Header
- Output only links using wp_nav_menu()
- Need help removing […] after excerpt
- How to add aria role and schema markup to custom walker container
- Twentyfifteen style author comment
- Extend Menu Walker Output
- Removed jQuery script from header.php , any problems?
- How to correctly load a different version of main menu based on the user language in WordPress? Is it a good solution?
- conditional: if is page, and all subpages
- Trying to change featured image from 180×180 to full width on home page
- Remove the Tag from wp_nav_menu
- WordPress redirects page query parameter in URL
- Getting text from custom field from customizer
- WordPress navigation wont appear with wp_head
- Need help for some PHP code
- How do you get the current post taxonomy so I can get the current post taxonomy? into a variable to THEN loop through all post with that taxonomy.,
- Background image no longer fits to screen now that project is in php files
- how to replace h1 entry title with h2 in category pages only
- How to make only the valid active page of a multilevel menu active with – “.nav li.current-menu-item a”?
- I can’t go to the page archive-{post_type}.php
- I have a background-image in css file but don’t show in site.how to fix this prblm. i sent screenshot. thx
- Display post date also if the date it’s the same for each post
- Submit remote form to wordpress REST API and save data to custom post type
- I cannot find the wordpress.scss file that my live site is pulling from
- alternate left – right content inside the loop
- I have a lot of JavaScript erorrs after SSL someone can help me?
- Collapsible menu on post sidebar only expands and does not collapse
- custom field – changing an element or background of id div – different versions not working
- Woocommerce variable products are being added to the card on the homepage (ajax)
- user update profile for custom code
- How to get php file based on URL in WordPress
- I want different post-thumbnail size depending on media size
- Create a custom theme-specific page, invisible in the admin-panel?
- A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
- Image not displayed
- Show contact 7 form in popup
- Adding code to the function file
- Converting Menu Links to List Elements
- WP_Query not returning results
- Using is home to get content [closed]
- How I can give a php page a style from my theme
- How do I link the side images?
- How to create a container in php then customise it in CSS