Trim titolo
-
Salve,
sto utilizzando questo snippet per effettuare il trim del titolo di un post
=======================
function summary4($content, $limit = 200) {
$content = strip_tags($content);
// Take the existing content and return a subset of it
$end = ”;
if (strlen($content) > $limit) {
$end = ‘…’;
}
return substr($content, 0, $limit) . $end;
}add_action( ‘elementor/query/attualita’, function( $query ) {
function trimTitle3( $title, $id = null ) {
return summary4($title,10);
}
$query->set(‘post_type’, ‘news’);
/*add_filter( ‘the_title’, ‘trimTitle3’, 10, 2 );*/} );
==========================
Lo snippet assolve al suo dovere, e tronca effettivamente il titolo di tutti i post contenuti nel post_type news.
Vorrei però affinare il filtro inserendo anche una specifica categoria. Ho provato quindi ad aggiungere $query->set(‘term’, ‘cronaca’); ma non funziona
- Il topic ‘Trim titolo’ è chiuso a nuove risposte.