From b2c2e3cd6501f12e6d2066fd5a2f0ee58fb063fd Mon Sep 17 00:00:00 2001 From: jorge-vitrubio Date: Tue, 19 Jul 2022 00:27:21 +0200 Subject: [PATCH] changed excerpt in category when long length goes out of the box, specially in arxives category --- caixes.php | 357 +++++++++++++++++++++++++++----------------------- category.php | 76 +++++------ functions.php | 157 +--------------------- 3 files changed, 239 insertions(+), 351 deletions(-) diff --git a/caixes.php b/caixes.php index 7cfa620..2251cc1 100644 --- a/caixes.php +++ b/caixes.php @@ -1,180 +1,209 @@
  • > - - + +

    - -
    - -
    -
    - enllaç -
    - - - - -
    - - - - -

    - -

    - + +
    +
    - ID, 'autor_tipo_resid', true) && get_post_meta($post->ID, 'autor_data_resid', true)): ?> -

    - ID, 'autor_tipo_resid', true)) ?> -
    - ID, 'autor_data_resid', true)) ?> -

    - -

    - - -

    ID, 'data_obra', true) ?>

    - - - - - - - imatge no disponible - -
    - - enllaç - - - - enllaç a la categoria + enllaç +
    + + + + +
    + + + + +

    + +

    + +
    + ID, 'autor_tipo_resid', true) && get_post_meta($post->ID, 'autor_data_resid', true)): ?> +

    + ID, 'autor_tipo_resid', true)) ?> +
    + ID, 'autor_data_resid', true)) ?> +

    + +

    - -
    - - - ID, 'carrec', true); - elseif($lang == 'es'): - $carrec = get_post_meta($post->ID, 'carrecES', true); + +

    ID, 'data_obra', true) ?>

    + + + + + + + imatge no disponible + + +
    + + enllaç + + + + enllaç a la categoria + + +
    + + +ID, 'carrec', true); + elseif($lang == 'es'): + $carrec = get_post_meta($post->ID, 'carrecES', true); elseif($lang == 'en'): $carrec = get_post_meta($post->ID, 'carrecEN', true); endif; $email = get_post_meta($post->ID, 'email', true); - $telefon = get_post_meta($post->ID, 'telefon', true); - ?> -
    -

    -

    -
    -

    -

    - - - - - - - imatge no disponible - - - -

    - -
    - + $telefon = get_post_meta($post->ID, 'telefon', true); + ?> +
    +

    +

    +
    +

    +

    - - - -
    - - - - -

    - -

    - - -
    -
    - -
    - - -
    - enllaç - - - enllaç a la categoria - -
    - - - - - term_id;?> -
    - - - name;?> - -

    - - - - name;?> - -

    - - -

    - - -
    - + + + + + imatge no disponible + + + +

    + +
    + + + + + +
    + + + + +

    + +

    + + +
    +
    + +
    + + +
    + enllaç + + + enllaç a la categoria + +
    + + + + + term_id;?> +
    + + + name;?> + +

    + + + + name;?> + +

    + + +

    + + +
    + ID, 'data_activitat', true) )): - ?>

    ID, 'data_activitat', true); if (get_post_meta($post->ID, 'horari_activitat', true)) echo " / ".get_post_meta($post->ID, 'horari_activitat', true); if (get_post_meta($post->ID, 'lloc_activitat', true)) echo " - ".get_post_meta($post->ID, 'lloc_activitat', true); ?>

    ID, 'data_activitatES', true) )): - ?>

    ID, 'data_activitatES', true); if (get_post_meta($post->ID, 'horari_activitat', true)) echo " / ".get_post_meta($post->ID, 'horari_activitat', true); if (get_post_meta($post->ID, 'lloc_activitat', true)) echo " - ".get_post_meta($post->ID, 'lloc_activitat', true); ?>

    ID, 'data_activitatEN', true) )): - ?>

    ID, 'data_activitatEN', true); if (get_post_meta($post->ID, 'horari_activitat', true)) echo " / ".get_post_meta($post->ID, 'horari_activitat', true); if (get_post_meta($post->ID, 'lloc_activitat', true)) echo " - ".get_post_meta($post->ID, 'lloc_activitat', true); ?>

    -

    - - - - - - - - - - -

    - -
    - - - -
    - enllaç - - - enllaç a la categoria - -
    - + ?> +

    + ID, 'data_activitat', true); + if (get_post_meta($post->ID, 'horari_activitat', true)) echo " / ".get_post_meta($post->ID, 'horari_activitat', true); + if (get_post_meta($post->ID, 'lloc_activitat', true)) echo " - ".get_post_meta($post->ID, 'lloc_activitat', true); + ?> +

    + ID, 'data_activitatES', true) )): + ?> +

    + ID, 'data_activitatES', true); + if (get_post_meta($post->ID, 'horari_activitat', true)) echo " / ".get_post_meta($post->ID, 'horari_activitat', true); + if (get_post_meta($post->ID, 'lloc_activitat', true)) echo " - ".get_post_meta($post->ID, 'lloc_activitat', true); + ?> +

    + ID, 'data_activitatEN', true) )): + ?> +

    + ID, 'data_activitatEN', true); + if (get_post_meta($post->ID, 'horari_activitat', true)) echo " / ".get_post_meta($post->ID, 'horari_activitat', true); + if (get_post_meta($post->ID, 'lloc_activitat', true)) echo " - ".get_post_meta($post->ID, 'lloc_activitat', true); + ?> +

    + +

    + -
  • + + + + + + + +

    + ID) . '">[...]') + ?> +

    + +
    + + +
    + enllaç + + + enllaç a la categoria + +
    + + + diff --git a/category.php b/category.php index c3243a1..0cc1965 100644 --- a/category.php +++ b/category.php @@ -1,13 +1,13 @@ - @@ -19,44 +19,46 @@ get_header(); ?>
    >
    '; - echo single_cat_title( '', false ) ; echo '' ; ?> - - '. category_description(). '
    '; - endif; - ?> + echo single_cat_title( '', false ) ; echo '' ; ?> + + '. category_description(). '
    '; + endif; + ?> - - - + + + +
    - +
    + + + +

    + +

    + + + - - - diff --git a/functions.php b/functions.php index e7f9a09..3947132 100644 --- a/functions.php +++ b/functions.php @@ -1,4 +1,4 @@ -ID) . '"> [...]'; } -add_filter('excerpt_more', 'new_excerpt_more'); +add_filter('excerpt_more', 'hangar_excerpt_more'); // custom login screen i peu de l'admin function custom_login() { - //echo ''; - // time stamp for caching - // https://developer.wordpress.org/reference/functions/wp_enqueue_style/#comment-2056 echo ''; } add_action('login_head', 'custom_login'); -//function change_wp_login_url() { -//echo bloginfo('url'); -//} -//add_filter('login_headerurl', 'change_wp_login_url'); - -//function change_wp_login_title() { -//echo 'Powered by ' . get_option('blogname'); -//} -//add_filter('login_headertitle', 'change_wp_login_title'); - function remove_footer_admin () { echo 'Custom text | Copyright © message'; } add_filter('admin_footer_text', 'remove_footer_admin'); -// THIS GIVES US SOME OPTIONS FOR STYLING THE ADMIN AREA -function custom_controls() { - // echo ''; -} - -add_action('admin_head', 'custom_controls'); - -/* create calendar event when saving post with dates */ -// function create_event( $post_id ) { -// -// // If this is just a revision, don't send the email. -// if ( wp_is_post_revision( $post_id ) ) -// return; -// -// $myPost = get_post($post_id); -// if (has_category(array('news', 'activitats-dels-residents'), $post_id) && -// !$update && -// $myPost->post_modified_gmt == $myPost->post_date_gmt) { -// -// //The URL that we want to send a PUT request to. -// $uid = get_the_guid( $post_id ); -// $url = 'https://cloud.hangar.org/remote.php/dav/calendars/hangar/hangar_activitats/neu.ics'; -// $headers = array('Content-Type: text/calendar', 'charset=utf-8'); -// $userpwd = 'hangar:AV63xlklCuOJgYTnHz5smX4chiAaDpJo'; -// $description = get_the_content( $post_id ); -// $summary = get_the_title( $post_id ); -// $tstart = gmdate("Ymd\THis\Z", strtotime("-2 days")); -// $tend = gmdate("Ymd\THis\Z", strtotime("-2 days")); -// $tstamp = gmdate("Ymd\THis\Z"); -// -// // vcalendar -// $body = 'BEGIN:VCALENDAR -// VERSION:2.0 -// BEGIN:VEVENT -// DTSTAMP:$tstamp -// DTSTART:$tstart -// DTEND:$tend -// UID:$uid -// DESCRIPTION:$description -// LOCATION:Hangar -// SUMMARY:$summary -// END:VEVENT -// END:VCALENDAR'; -// -// //Initiate cURL -// $ch = curl_init($url); -// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -// curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); -// curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); -// curl_setopt($ch, CURLOPT_USERPWD, $userpwd); -// //curl_setopt($ch, CURLOPT_PUT, true); -// curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); -// curl_setopt($ch, CURLOPT_POSTFIELDS, $body); -// -// //Execute the request. -// $response = curl_exec($ch); -// curl_close($ch); -// -// // send confirmation mail -// $post_title = $summary; -// $post_excerpt = $description; -// $post_url = get_permalink( $post_id ); -// $subject = 'A new EVENT post has been saved'; -// -// $message = "A new post has been created on your website:\n\n"; -// $message .= $post_title . ": " . $post_url . "\n\n"; -// $message .= $post_excerpt . "\n\n"; -// $message .= $uid . "\n\n"; -// $message .= print_r($response); -// -// // Send email to admin. -// wp_mail( 'gerald@hangar.org', $subject, $message ); -// } -// } -// add_action( 'save_post', 'create_event', 10, 3 ); //per imprimir el content sense que ens tregui l'html function get_the_content_with_formatting ($more_link_text = '(...)', $stripteaser = 0, $more_file = '') { @@ -154,24 +60,6 @@ function get_the_content_with_formatting ($more_link_text = '(...)', $striptease $content = substr($content, 0,400); return $content; } -//per imprimir l'excerpt indicant un nombre de caràcters màxim -// function the_excerpt_max_charlength($charlength) { -// $excerpt = get_the_excerpt(); -// $charlength++; -// if(strlen($excerpt)>$charlength) { -// $subex = substr($excerpt,0,$charlength-5); -// $exwords = explode(" ",$subex); -// $excut = -(strlen($exwords[count($exwords)-1])); -// if($excut<0) { -// echo substr($subex,0,$excut); -// } else { -// echo $subex; -// } -// echo "[...]"; -// } else { -// echo $excerpt; -// } -// } //afegir estils a l'editor @@ -248,7 +136,7 @@ function has_subcategories($catt) endif; } -//contruim un panell de control a l'administració per a que vegin les que estan marcades per a sortir a la home +//construim un panell de control a l'administració per a que vegin les que estan marcades per a sortir a la home function menu_control_home(){ add_menu_page( "Control Home","Control Home", "add_users", "control_home", "control_home", "", 6 ); } @@ -374,37 +262,6 @@ class my_Walker_Nav_Menu extends Walker_Nav_Menu { ', ']]>', $text); - - //Add the allowed HTML tags separated by a comma. - $allowed_tags = '

    ,,,'; - $text = strip_tags($text, $allowed_tags); - - //Change the excerpt word count. - $excerpt_word_count = 60; - $excerpt_length = apply_filters('excerpt_length', $excerpt_word_count); - - //Change the excerpt ending. - $excerpt_end = ' ' . '» Continue Reading.' . ''; - $excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end); - - $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY); - if ( count($words) > $excerpt_length ) { - array_pop($words); - $text = implode(' ', $words); - $text = $text . $excerpt_more; - } else { - $text = implode(' ', $words); - } -}*/ // https://stackoverflow.com/questions/15283948/wordpress-html-tags-strip-on-manual-excerpt function custom_wp_trim_excerpt($text='') { @@ -429,7 +286,7 @@ if ( '' == $text ) { $excerpt_word_count = 200; /*** MODIFY THIS. change the excerpt word count to any integer you like.***/ $excerpt_length = apply_filters('excerpt_length', $excerpt_word_count); - $excerpt_end = '[...]'; /*** MODIFY THIS. change the excerpt endind to something else.***/ + $excerpt_end = ' [...]'; /*** MODIFY THIS. change the excerpt endind to something else.***/ $excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end); $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);