Private Post BUT Public excerpt on Homepage

You could add this to your themes functions.php file. This adds private posts to the initial loop on the homepage only. /** * Include private posts in homepage loop */ function show_private_posts_on_homepage($query) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘post_status’, array( ‘publish’, ‘private’ ) ); } } add_action(‘pre_get_posts’, ‘show_private_posts_on_homepage’); Depending on your theme, … Read more

How to edit a typo in excerpt?

You probably have the excerpt set to hidden in the edit screen. Open your post for editing, click the Screen Options in the top right corner of screen, and then check the Excerpt box. After that, you can see the excerpt as a box in the edit post screen.

Use get_the_excerpt is returning nothing outside of loop

If the post does not have a manual excerpt (as in one added to the Excerpt box on the post edit screen) then get_the_excerpt() used wp_trim_excerpt() to generate an excerpt. The problem is that wp_trim_excerpt() uses the content of the global $post object, which is set in the loop, regardless of any ID passed to … Read more

Split the_content into two parts

Solution one: As the wise commenter mentioned, you can use excerpts. the_excerpt() (link) “retrieves the post excerpt”. get_the_excerpt() is going to be a string so you can wrap it up in whatever you fancy and after that, you can call the_content() to get the rest. The only downside that I see is that you’ll have … Read more

PHP Code in excerpt?

Any PHP code in the post content will get stripped out and not executed. This is a safety issue; you don’t want to allow authors to put in executable code. To display code in a post, BTW, you would surround it with the <code> tag, If you want to modify what the excerpt displays, you … Read more

I want to show post excerpt and cap it at 20 words [duplicate]

You can use filters to change the excerpt length. (It goes in your theme or child theme’s functions.php) function wpdocs_custom_excerpt_length( $length ) { return 70; } add_filter( ‘excerpt_length’, ‘wpdocs_custom_excerpt_length’, 999 ); At this point I usually also like to change the part that gets added to the end of a truncated excerpt to something like … Read more

Is it possible to use words as starting and ending points of excerpt parameters?

I think this is more a PHP than a WP question. Try using a regular expression with preg_match: $theExcerpt = get_the_content(); $returnValue = preg_match(‘/(string01)(.*)(string02)/’, $theExcerpt); echo $returnValue[0]; You have to replace string01 and string02 with your ‘begining of paragraph’ and ‘end of paragraph’. There might be a more elegant way of using preg_match, but I … Read more

the_excerpt is not limiting my post page to 55 words?

Hi @janoChen: Are you sure that code it running and not some other code? I just traced through the code and the only way it’s going to do that is if you have a plugin or code in your theme that is hooking one of the following hooks: ‘the_excerpt’, ‘get_the_excerpt’, ‘wp_trim_excerpt’ or possibly removed the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)