Thread Starter
Matt
(@syntax53)
post edited — I was wrong, the shortcode i originally posted was not causing this. trying to figure out what is.
Thread Starter
Matt
(@syntax53)
So it is being caused by the shortcode I thought it was, but not when displayed directly on the page. It’s being caused by a custom function I wrote that creates an excerpt from the content of the page when “get_the_excerpt()” returns nothing in a list of recent posts. My function is as follows–
function custom_excerpt_length($length){
$excerpt = do_shortcode( get_the_content() );
$excerpt = strip_tags($excerpt, '<br><li><p>');
$excerpt = str_ireplace(array('<br>'), array(', '), $excerpt);
$excerpt = str_ireplace(array('<li>','</li>'), array(', ', ''), $excerpt);
$excerpt = str_ireplace(array('<p>','</p>'), array(', ', ''), $excerpt);
while (substr($excerpt, 0, 1) == ',') { $excerpt = substr($excerpt, 1); }
$excerpt = trim($excerpt);
if (strlen($excerpt) > $length) {
$permalink = get_permalink();
$excerpt = substr($excerpt, 0, $length);
$excerpt = substr($excerpt, 0, strripos($excerpt, " "));
$excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt));
$excerpt = $excerpt.'... <a href="'.$permalink.'">more</a>';
}
return $excerpt;
}
The “$excerpt = do_shortcode( get_the_content() );” is causing it. This is being ran in the loop on a homepage set to show the most recent posts. The shortcode is–
[mla_gallery mla_link_attributes=’rel=”none”‘ attachment_category=board-governance mla_style=mla-policy-list-ul mla_markup=mla-policy-list-ul post_parent=all orderby=title order=asc post_mime_type=all link=file]
Thread Starter
Matt
(@syntax53)
fyi– i tried updating to the latest development version and it did not fix it.
Thread Starter
Matt
(@syntax53)
wow, ok. I tracked it back even further to another custom function that I wrote where I was hooking “pre_get_posts” to add pages to the loop, but only if they were 1 month old or newer. I just had to modify that query to include the table name ($wpdb->prefix.’posts’). I guess you are also hooking that somewhere? Either way, ignore my ramblings I suppose 🙂
Thanks for tracking this down and resolving it before I could muddy the waters. As you suspected, MLA hooks quite a few filters to support the query enhancements in, for example, [mla_gallery].
I have been on both sides of the “warring filters” experience and I can relate to your adventures.
If there’s anything else I can do to make your MLA experience better, let me know. Thanks for your persistence and your interest in the plugin.