How to show excerpt field
Try to using this in your function.php file and let me know if any query add_post_type_support( ‘page’, ‘excerpt’ );
Try to using this in your function.php file and let me know if any query add_post_type_support( ‘page’, ‘excerpt’ );
You can create the custom post types for Press Releases, News etc with external website links with this plugin. You have to just list those custom post types where you want to display those.
There are various ways to achieve this as listed following. Using wordwrap() function : function shortened_description($cutlength) { $content = get_field(‘event_short_description’); $charcount = strlen($content); $content = wordwrap($content, 28); $content = explode(“\n”, $content); $shorter = $content[0]; if ($charcount >= $cutlength) { echo $shorter . ‘… <a href=”‘ . get_permalink() . ‘”>more ></a>’; } //$charcount >= $cutlength else … Read more
To append strings in PHP use ., like: return $sentence[‘0’] . $sentence[‘1’] . “… Read More”;
the_content echoes post content. It does not return a string that you can manipulate. You need get_the_content() Swap those functions and it should work.
You can use this function wp_trim_words(). It allows you to format the output, and strips all the HTML tags in the content (it uses wp_strip_all_tags). You will have to pass post_content as the first paramenter.
Answer on my own question (without using a plugin and choosing a middle way) for what we want to achieve. Because the template has also a code starting with: if ( has_post_thumbnail() && ( $post->post_type == ‘post’ ) ) we have taken that part of code away. (we won’t used it in postings/pages, therefore) Following … Read more
The get_template_part(‘content’, get_post_format()); line includes content from one of the other files in your theme based on the post type, the file name will be something like content-page.php (or content.php if the format is not found). If you print out what get_post_format() returns, you will be able to tell which content file to look into. … Read more
Depending on where in the loop you call excerpt() wpautop might be creating the <p>…</p> wrapper. In that case, you could wrap $excerpt with <p>…</p> before returning it. Edit: Try this approach <?php echo excerpt(25).”\n”;?> (or possibly “\n\n”) to change the behavior. in function awesome_excerpt() you have $text = substr( $content, 0, strpos( $content, ‘</p>’ … Read more
Does that post have an excerpt manually entered? the filter only works on excerpts when they’re pulled from the post content.