i try to show the excerpt on a page without content permission.
I looked into the code at /inc/functions-content-permissions.php
on line 148 and 149 you where adding the filter to replace the excerpts content with the permission error message. https://github.com/caseproof/members/blob/c6556a93def04d0a6bbf65bad57a2ef3f5e1c729/inc/functions-content-permissions.php#L148
When i display the excerpt directly on the same page the error message comes up double and showing the excerpt would not break the permission in my case.
I tried the following:
add_action('init', 'myPlugin_init');
function myPlugin_init(){
remove_filter('get_the_excerpt', 'members_content_permissions_protect', 95);
remove_filter('the_excerpt', 'members_content_permissions_protect', 95);
}
https://developer.www.ads-software.com/reference/functions/remove_filter/
but it still shows up.
also i looked into the filter ‘members_post_error_message’ but i can’t determine if its shown at a content, excerpt or comment field.
i would apprechiate any pointer to the right direction
best
tom
I have a meta description in the head of my WP website that can contain line breaks… The native post excerpt/summary is my meta description for that post, so I’m using get_the_excerpt()
to retrieve it.
According to the codex this excerpt should not contain line breaks, all HTML tags should be stripped off.
Before adding preg_replace
to replace the line breaks I would like to know what’s happening here? Is it because it’s printed in the head perhaps?
Guido
]]>Best would be to not run the juggernout content filter if called when generation an excerpt (As links will be stripped off the excerpt anyway).
Here is the patch I suggest for fixing this, would be nive if this could get included in the next update:
Index: content-autolinks.php
===================================================================
— content-autolinks.php (revision 17536)
+++ content-autolinks.php (revision 27235)
@@ -57,6 +57,12 @@
function autolink_content($content) {
+ // TODO cgaffga: no auto-linker when generating excerpt
+ $stacktrace = debug_backtrace();
+ foreach ($stacktrace as $step) {
+ if($step->function == ‘wp_trim_excerpt’) return;
+ }
+
$links = $this->get_setting(‘links’, array());
if (!count($links)) return $content;
…maybe a setting to activate it would be nice, but I think it’s good to have it always on.
hope this is of help.
kindly,
Christoph
Been googling around a bit and can’t find a solution, so wondering if anyone has the answer here. A few people seem to have this problem, but nobody’s posted a fix that I can see here, on StackOverflow, or elsewhere.
I have a shortcode plugin which displays a table of objects (kindof like a product list). The code gets a wp_query ($plant_lists) from a selection of posts in a custom taxonomy, and then loops through building the table, as follows:
$plant_lists = new WP_Query(array(
'order' => 'ASC',
'orderby' => 'title',
// menu_order ID
'plant_list_category' => $cat,
'post_type' => 'plant_lists',
'post_status' => null,
'nopaging' => 1,
'posts_per_page' => -10) );
$plant_shortcode .= '<table class="planttable"><tbody>';
while($plant_lists->have_posts()): $plant_lists->the_post();
$countPlants++;
$family=get_post_meta( get_the_ID(), '_plant_lists_family', true );
$theimage=wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()) , 'plant-image');
$plant_shortcode .= '<tr><td align="center"><a href="' . get_permalink() . '"><img src="'.$theimage[0].'" alt="" /></a></td>';
$plant_shortcode .= '<td><div class="plant-title"><a href="' . get_permalink() . '">'. get_the_title().'</a></div>';
$plant_shortcode .= '<div class="plant-excerpt">';
if($family != NULL){
$plant_shortcode .= '<p><b>Family: '.$family.'</b></p>';
}
$plant_shortcode .= '<p>'. get_the_excerpt().'</p>';
$plant_shortcode .= '</div></td></tr>';
endwhile; // end slideshow loop
$plant_shortcode .= '</tbody></table>';
if ($countPlants == '0') {
$plant_shortcode = 'No plants are currently posted in this category';
}
wp_reset_query();
The problem I’m having is that the ‘Continue Reading’ link for each excerpt links to the current page, rather than the page for the post/document. I can’t see any reason that this would happen, and no matter what I try I can’t fix it.
The page in question is here: https://www.pumpkinbeth.com/plants/
Anyone got any ideas?
]]>add_filter( 'get_the_excerpt', 'excerpt_custom_content' );
function excerpt_custom_content($content){
if( is_post_type_archive('teachings') ) {
$content .= '<p>custom content</p>';
}
return $content;
}
that get the custom content to display in the excerpts on the archive pages for my custom post type, but then i ran into a problem when I created a custom taxonomy (book) for my custom post type (teaching), and added a link to my menu to display the posts which selected ‘deuteronomy’ in the ‘book’ taxonomy (so the link looks like this “calvary2sun.com/book/deuteronomy).
To the best of my understanding this is a category archive page, so I entered the code
add_filter( 'get_the_excerpt', 'excerpt_custom_content_cat' );
function excerpt_custom_content_cat($content){
if(is_category() ) {
$content .= '<p>custom content</p>';
}
return $content;
}
in my functions.php but nothing changed on the page.
I’ll also need it to only apply to my custom post type ‘teachings’, so… I’m very much at a loss on this one, and would appreciate any bit of help.
thank you very much for reading this posts and thank you in advance for any help you provide!
]]>Since the upgrade, get_the_excerpt returns a blank string on my index.php
However, if I change code to call the_excerpt (not get_the_excerpt), then the proper excerpt will display. However, it begins with a line break that I don’t want. I think this was the reason I switched the code to get_the_excerpt.
— Relevant code in index.php:
<div class="entry-date"><strong><?php unset($previousday); printf( __( '%1$s – %2$s', 'sandbox' ), the_date( '', '', '', false ), '' ) ?></strong>
<?php echo get_the_excerpt( __( 'Read More <span class="meta-nav">»</span>', 'sandbox' ) ) ?></div>
<div style="padding-bottom:10px;"></div>
— Relevant code in functions.php (I’ve tried commenting it out to no avail)
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
— I’ve tried logging out of WP admin, clearing my cache/cookies, different browsers, and disabling all plugins. It did not affect the behaviour.
Any help would be appreciated. Thanks.
PS: I am not a WordPress guru.
get_the_excerpt was called with an argument that is deprecated since version 2.3 with no alternative available
After disabling the Plugin the error stopped.
What can I do to fix this problem?
Plugin Version> 3.4.27
https://www.ads-software.com/plugins/social-networks-auto-poster-facebook-twitter-g/
]]>https://www.ads-software.com/plugins/facebook-thumb-fixer/
]]>For some reason the_excerpt(); and echo get_the_excerpt(); give me the excerpt for the product type and not the product
Here’s my single-product_type.php
<?php
/**
* The template for displaying product category post type
*
* @package WordPress
* @subpackage FoundationPress
* @since FoundationPress 1.0
*/
get_header(); ?>
<div class="row">
<?php do_action( 'foundationpress_before_content' ); ?>
<?php while ( have_posts() ) : the_post(); ?>
<article <?php post_class() ?> id="post-<?php the_ID(); ?>">
<?php do_action( 'foundationpress_post_before_entry_content' ); ?>
<div class="entry-content">
<div class="row">
<div class="column">
<div class="text-center">
</div><!--text-center-->
<div class="skinnycol">
<header class= text-center>
<h1 class="entry-title brand-color"><?php the_title(); ?></h1>
<?php the_content(); ?>
</header>
</div><!--skinnycol-->
</div><!--column-->
</div><!--row-->
</div> <!--entry content-->
<footer>
<?php wp_link_pages( array('before' => '<nav id="page-nav"><p>' . __( 'Pages:', 'foundationpress' ), 'after' => '</p></nav>' ) ); ?>
<p><?php the_tags(); ?></p>
</footer>
</article>
<?php endwhile;?>
<?php wp_reset_postdata(); ?>
<?php
$product_types = get_posts(array(
'post_type' => 'products',
'posts_per_page' => 5000,
'meta_query' => array(
array(
'key' => 'product_type_dude', // name of custom field
'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
)
)
));
?>
<?php if( $product_types ): ?>
<ul class="product-list">
<?php foreach( $product_types as $product ): ?>
<?php $excerpt = get_the_excerpt( $product->ID ); ?>
<li class="clearfix archive-item">
<div class="small-12 medium-4 columns">
<a href="<?php echo get_permalink( $product->ID ); ?>">
<?php echo get_the_post_thumbnail($product->ID,'thumbnail'); ?>
</a>
</div>
<div class="small-12 medium-8 columns">
<a href="<?php echo get_permalink( $product->ID ); ?>">
<h4 class="brand-color"><?php echo get_the_title( $product->ID ); ?></h4>
</a>
<?php echo get_the_excerpt( $product->ID ); ?> <!-- why doesn't this work? -->
</br></br>
<a href="<?php echo get_permalink( $product->ID ); ?>">
Read more about <?php echo get_the_title( $product->ID ); ?>
</a>
</div>
</li>
<hr>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php do_action( 'foundationpress_after_content' ); ?>
</div>
<?php get_footer(); ?>
you can see I tried <?php wp_reset_postdata(); ?>
to no avail.
Why would it call all the right titles, featured images, and permalinks but not the correct excerpt. I tried the_content();
as well and it did the same thing.
Here’s is a link to the page where you can see all the excerpts repeating: https://silence.kevinalves.me/product_type/baffles/
HALP
Thanks in advance!