How to obtain a reference to the_excerpt() from custom loop
I think you have to setup_postdata() with get_posts() to get things that rely on global variables to work. or explicitly pass the post id with the function.
I think you have to setup_postdata() with get_posts() to get things that rely on global variables to work. or explicitly pass the post id with the function.
I’m going to assume that you’re calling get_blog_excerpt() in your template somewhere? If so, what happens if you simply call the_excerpt(), and then pull the two add_filter() calls out of the container function? i.e. functions.php would just look like: function ce4_excerpt_length($length) { return 150; } add_filter(‘excerpt_length’, ‘ce4_excerpt_length’); function ce4_excerpt_more($more) { global $post; return ‘…<a href=”‘. … Read more
The Facebook Page Publish plugin is adding the og:description. Looking through the code in fpp_index.php at lines 843 – 851: $description = array(); if ($options[‘show_post_author’]) { $description[] = esc_attr(fpp_get_post_author($post));/*, ENT_COMPAT, ‘UTF-8’)*/ } if ($options[‘show_post_categories’]) { $categories = esc_attr(fpp_get_post_categories($post));/*, ENT_COMPAT, ‘UTF-8’)*/ if (!empty($categories)) $description[] = $categories; } echo ‘<meta property=”og:description” content=”‘.implode(‘ | ‘, $description).'”/>’; It appears … Read more
Looks like my other answer wasn’t working, so I looked into it and found this: http://aaronrussell.co.uk/legacy/improving-wordpress-the_excerpt/ That article should give you all you need to keep the <p> tags in there.
Try using $post->post_excerpt instead: // globalize $post, just in case global $post; // find out if the post has a defined excerpt $data = $post->post_excerpt; // If so, output something if ($data) echo “<div class=”excerpt”>$data</div>”; This method will bypass the auto-excerpt generation inherent in get_the_excerpt(). EDIT By popular demand, the same code, using has_excerpt(): // … Read more
I recently wrote code that I just put into a new page template that does exactly this. The all you do is assign the parent pages that specific template (or any page you wish to have this functionality on) and then it’ll list it’s child pages with their featured images as thumbs. Getting a plugin … Read more
You could always use the has_excerpt() function to test for excerpt content and if it is not filled in you could display a message. Example: if( has_excerpt() ) { the_excerpt(); } else { echo ‘<p>Please enter the excerpt.</p>’; }
Thank you for all your help, especially @byronyasgur for your last suggestion. It helped me fix it. I was using markdown as the input format for the content, and the first line was HTML comment which was not followed by a blank line. Adding a blank line fixed it. Summary: The absence of this line … Read more
Custom API Write a normal API wrapper function for it and place it in your functions.php theme or offer it as (mu-)plugin. Trim Words /** * Trim Words Cb fn * @link Adjusted from http://snipplr.com/view.php?codeview&id=20397 * * @param string $excerpt Input string * @param int $count Word count * @param boolean/string $more Whether to show … Read more
Issue 1: creating the excerpt data This should be fairly easy to do directly with SQL. UPDATE wp_posts AS post INNER JOIN wp_posts AS attachment ON attachment.post_type=”attachment” AND post.ID = attachment.post_parent SET post.post_excerpt = CONCAT(‘<img src=”‘, attachment.guid,'” />’) WHERE post.post_excerpt=””; This is obviously a “one-time fix” that implies you have access to the database. If … Read more