Tagged: x
-
AuthorPosts
-
May 17, 2016 at 11:04 am #995713
mtusaParticipantWhen you search on our website, the results show what looks like code. (view picture below)
How do we fix this?May 17, 2016 at 11:05 am #995716
mtusaParticipantThis reply has been marked as private.May 17, 2016 at 12:29 pm #995867
ThaiModeratorHi There,
Please add the following CSS under functions.php file locates in child theme:
function x_allowedtags() { // Add custom tags to this string return '<script>,<style>,<br>,<em>,<i>,<ul>,<ol>,<li>,<a>,<p>,<img>,<video>,<audio>'; } if ( ! function_exists( 'x_custom_wp_trim_excerpt' ) ) : function x_custom_wp_trim_excerpt($wpse_excerpt) { global $post; $raw_excerpt = $wpse_excerpt; if ( '' == $wpse_excerpt ) { $wpse_excerpt = get_the_content(''); $wpse_excerpt = strip_shortcodes( $wpse_excerpt ); $wpse_excerpt = apply_filters('the_content', $wpse_excerpt); $wpse_excerpt = str_replace(']]>', ']]>', $wpse_excerpt); $wpse_excerpt = strip_tags($wpse_excerpt, x_allowedtags()); /*IF you need to allow just certain tags. Delete if all tags are allowed */ //Set the excerpt word count and only break after sentence is complete. $excerpt_word_count = 75; $excerpt_length = apply_filters('excerpt_length', $excerpt_word_count); $tokens = array(); $excerptOutput = ''; $count = 0; // Divide the string into tokens; HTML tags, or words, followed by any whitespace preg_match_all('/(<[^>]+>|[^<>\s]+)\s*/u', $wpse_excerpt, $tokens); foreach ($tokens[0] as $token) { if ($count >= $excerpt_word_count && preg_match('/[\,\;\?\.\!]\s*$/uS', $token)) { // Limit reached, continue until , ; ? . or ! occur at the end $excerptOutput .= trim($token); break; } // Add words to complete sentence $count++; // Append what's left of the token $excerptOutput .= $token; } $wpse_excerpt = trim(force_balance_tags($excerptOutput)); $excerpt_end = ' <a href="'. esc_url( get_permalink() ) . '">' . ' » ' . sprintf(__( 'Read more about: %s »', 'wpse' ), get_the_title()) . '</a>'; $excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end); //$pos = strrpos($wpse_excerpt, '</'); //if ($pos !== false) // Inside last HTML tag //$wpse_excerpt = substr_replace($wpse_excerpt, $excerpt_end, $pos, 0); /* Add read more next to last word */ //else // After the content $wpse_excerpt .= $excerpt_end; /*Add read more in new paragraph */ return $wpse_excerpt; } return apply_filters('wpse_custom_wp_trim_excerpt', $wpse_excerpt, $raw_excerpt); } endif; remove_filter('get_the_excerpt', 'wp_trim_excerpt'); add_filter('get_the_excerpt', 'x_custom_wp_trim_excerpt');Hope it helps 🙂
May 25, 2016 at 9:49 am #1009149
mtusaParticipantFor some reason, when I entered it in, it gives me an error. see below:
Parse error: syntax error, unexpected ‘–‘ (T_DEC) in /home/content/p3pnexwpnas14_data01/13/3076913/html/wp-content/themes/x-child/functions.php on line 6Please advise.
Thank you!
May 25, 2016 at 11:06 am #1009305
RupokMemberHi there,
Can you post the complete code on your functions.php? I mean if you have any other code above the suggested code, we need to check that too. You can login with FTP and share the code with us. Meantime take off the suggested code to get rid of the error.
Thanks
May 25, 2016 at 11:38 am #1009358
mtusaParticipantThis reply has been marked as private.May 25, 2016 at 1:22 pm #1009554
RupokMemberHi there,
It seems you have already posted it in a new thread. So it’s not really convenient to ask help for same issue on multiple thread. It might create conflict or waste the time double. We’ll assist you on this on the new thread.
Hope this makes sense and consider this thread as closed.
Thanks
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-995713 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
