the_post() within switch_to_blog() altering my excerpt

I have a strange problem I'm facing when using WP_Query with multisite in a plugin I'm writing which hooks into add_meta_boxes. I'm wanting to display all post titles in a dropdown in a meta box. While adding or editing a post in blog no. 2 (it could be any blog no.), I am looping through blog no. 1 and getting post titles from a custom post type to populate in a select dropdown. This works as it should, but in …
Category: Web

Highlight search words in excerpt

I have designed and developed a responsive Wordpress site that is almost ready for launch for a client who is an actor and producer. I have been stuck on my requirements for the search results page for three days. My EXCERPT is far too long and includes repeated text from the Home page no matter what the search is for. Under the white links to the posts and pages for the search results, I want an excerpt of no more …
Category: Web

Remove Default Read More Link in Manual Excerpt RSS Feed

I have a site that displays manual excerpts on the blog post page: https://teralynnchilds.com/blog. I added a custom read more link using the snippet found here: https://wpmayor.com/add-read-link-manual-excerpts/ The RSS feed (https://teralynnchilds.com/feed) includes the manual excerpt, the custom read more link, AND a default read more link of "keep reading TITLE at SITE". I am trying to remove that default read more link from the feed but cannot find the source anywhere. How do I fix it some my feed only …
Category: Web

Custom wp_trim_words() function not trimming right

I have this custom wp_trim_words() function set to give me excerpts of only 20 words, and for the most part, it works fine. Except for some reason, on posts that contain lists, it outputs way more than 20 words. (See the posts at the bottom of this page.) How can I fix this? I tried removing <ul>,<ol>,<li>, from the function insight_allowedtags() but that did nothing. Ideally, I'd like to make the custom excerpt output at least 20 words and end …
Category: Web

WPBakery Page Builder Shortcode Showing On Front Page For Post

I am working on a new site and am having an issue with the WPBakery plugin. I assume its a custom version of WPBakery, since it's marked WPBakery Page Builder by VisualModo, which is who my theme is through. The problem I am having is tat on the front page, which is static, I have a section to show Blog items and they do show up, along with the short codes that are rendered correctly on that actual post. I …
Category: Web

Excerpt Length & List Category Posts Plugin

I'm trying to filter out the excerpt by character length for a plugin called "List Category Posts". I've been trying to get the excerpts working for the past week, but nothing is doing the trick. The plugin actually comes with a feature that allows you to post the excerpt or not, then filter it by character length.. by adding "excerpt_size=" in the shortcode. But unfortunately, it doesn't work at this time, and I've tested it with multiple different themes. Anyways, …
Category: Web

wp_trim_words is trimming by character instead of by words

I'm using Wordpress 3.9.2, and having trouble with the wp_trim_words function. It seems to be cutting the string down to X characters instead of X words. Example Put the following in a template file: <?php $str = "Imagine discovering a secret language spoken only online by a knowledgeable and learned few. Over a period of weeks, as you begin to tease out the meaning of this curious tongue and ponder its purpose, the language appears to shift in subtle but …
Category: Web

How to remove first three words from content and display the excerpt

Hi I am making a video game site. I can display the excerpt, shortened it as well after following some advice. What I can't do is remove the first three words from the content and then display it as excerpt . eg if the content is ... "the content starts this is the excerpt" after stripping the html tags so the_excerpt() should only display "this is the excerpt" The site I just want to remove description and instructions from each …
Category: Web

Cutting off excerpt with first sentence

I'm trying to end my excerpts with the first sentence. I had attempted the solutions I found on this website, including each function + add_filter from these posts: How to end the excerpt with a sentence rather than a word? and End excerpt at the end of the sentence It hasn't worked. I had checked that the filter is applied by adding the function: function print_filters_for( $hook = '' ) { global $wp_filter; if( empty( $hook ) || !isset( $wp_filter[$hook] …
Category: Web

Problem with site's search results "Read More" link?

I'm hoping someone will be able to help me with this issue. I noticed today that when I search certain serch terms in my Wordpress site's search box the link is messed up (shown in the image below outlined by the yellow boxes) and when clicked, the link takes the user to a blank page. When I searched other terms, either there was the issue on all of the search results for that term or there was no issue at …
Category: Web

Inserting shortcode is blanking excerpt - any ideas?

I wrapped a shortcode around my post content and I have noticed it is making the excerpt blank on archive pages instead of auto generating one from the_content/post. At a loss as to what is causing it or what to try. Its not even outputting the shortcode in the_excerpt its just blank. I would have thought if there was going to be a problem it would have been the shortcode appearing as part of the_excerpt but its just blank full …
Category: Web

add_filter on "the_excerpt" only works when post does not have excerpt

class my_menu extends WP_Widget { function widget($args, $instance) { // Excerpt length filter $new_excerpt_length = create_function('$length', "return " . $excerpt_length . ";"); if ( $instance["excerpt_length"] > 0 ) { add_filter('excerpt_length', $new_excerpt_length, 999); } //... } } This filter works great if the post does not have an excerpt. How do I apply the same filter to a post that has an excerpt? In other words, when the post has an actual excerpt, its not filtering it at all, the whole …
Category: Web

the_excerpt and shortcodes

I'm using the_excerpt on my index page. I'm also using a dropcap shortcode at the beginning of each of my posts. On the index page, the posts will not display the letter with the dropcap shortcode around it. If my post beings with the word "Dog" the index page displays "og". How do I get shortcodes to work when using the_excerpt? Shortcode function drcap ($atts, $content = null) { return '<div class="dropcap">' . do_shortcode($content) . '</div>'; } add_shortcode('dropcap', 'drcap');
Category: Web

run shortcode in excerpt of single custom post type

Hi because of the way my theme is set up, I need to run a shortcode inside the excerpt of a custom post type (services). This is the code I have so far... function do_my_shortcode_in_excerpt($excerpt) { if ( 'services' == get_post_type() ) { return do_shortcode(wp_trim_words(get_the_content(), 55)); } } add_filter('get_the_excerpt', 'do_my_shortcode_in_excerpt'); This works fine (I'll need to increase the 55) but it stops the excerpts appearing everywhere else. I only want this filter to run on excerpts associated with services - …
Category: Web

shortcode doesnt work on excerpt

My shortcodes don't seem on archive page excerpts. You can see an example excerpt: https://unit-test-data.deniz-tasarim.site/2011/03/15/ here is related code with an excerpt in my theme files: archive.php: <h3><?php the_title(); ?> </h3> <p class="project-dp-one"><?php the_excerpt(); //html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?></p> <a class="btn btn-lg ulockd-btn-thm2" href="<?php the_permalink(); ?>"><?php _e( ' Read More', 'hekim' )?></a> function.php: function hekim_excerpt_lenght_number(){ global $redux_demo; if ( is_numeric($redux_demo['text-excerpt-length'])==1 ) { add_filter( 'excerpt_length', function( $length ) { global $redux_demo; return $redux_demo['text-excerpt-length']; } ); } …
Category: Web

Allow HTML in excerpt

Here is my excerpt code. // Generate custom excerpt length function wpbx_excerpt_length($length) { return 300; } add_filter('excerpt_length', 'wpbx_excerpt_length'); How do I allow html like <a> <b> <i> <br>
Category: Web

Shortcodes showing in excerpt despite using strip_shortcodes

On my website, shortcodes are showing in the excerpts, despite the fact that WordPress should remove them automatically, and that I tried this two different solutions: function remove_shortcode_from_excerpt($content) { $content = strip_shortcodes( $content ); return $content; } add_filter('the_excerpt', 'remove_shortcode_from_excerpt'); And add_filter( 'the_excerpt', 'shortcode_unautop'); add_filter( 'the_excerpt', 'do_shortcode'); That I added in the functions.php file of my child theme. What are my next options?
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.