Trim the length of the ad title using CSS

Hello. I am using the following script to trim the header:

add_filter(
	'hivepress/v1/models/listing/fields',
	function($fields, $model){
		$fields['title']['max_length'] = 70;
		return $fields;	
	},
	1000,
	2
);

I need to display for example no more than 25 characters in the title of the ad. The rest of the characters should be hidden with css.

I have written the following css code:

.size {
    white-space: nowrap; 
    overflow: hidden; 
    padding: 5px; 
    background: #fc0; 
    position: relative; 
   }
   .size::after {
    content: ''; 
    position: absolute; 
    right: 0; top: 0; 
    width: 40px; 
    height: 100%; 
 
    background: -moz-linear-gradient(left, rgba(255,204,0, 0.2), #fc0 100%);
    background: -webkit-linear-gradient(left, rgba(255,204,0, 0.2), #fc0 100%);
    background: -o-linear-gradient(left, rgba(255,204,0, 0.2), #fc0 100%);
    background: -ms-linear-gradient(left, rgba(255,204,0, 0.2), #fc0 100%);
    background: linear-gradient(to right, rgba(255,204,0, 0.2), #fc0 100%);
   }

How do I assign this code to the title of the ad?

In case anyone didn’t realize, it’s something like this: How to Truncate Text with CSS and JavaScript

Hi,

Please note that the first PHP snippet will not allow you to save more than what you specify in the title when creating a listing. If you need to hide a part of the text, we recommend using the following options: overflow:hidden; and text-overflow:ellipsis;

​I hope this is helpful to you.

what is the ad header called in css? how do i assign my code to it?
can you fully write what to put in the additional css?

Hi,

Sorry for the inconvenience, but customization is beyond our support scope - it includes fixing bugs and guidance about the available features Support Policy | HivePress

If customizations are required for your site, please try customizing it using the collection of code snippets Search · user:hivepress · GitHub and other developer resources, or consider hiring someone for custom work https://fvrr.co/32e7LvY

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.