Excerpt length: get first paragraph

Assuming your paragraphs are marked with <p> tags, which can be set in the ACF field options, the following should work: function custom_field_excerpt() { global $post; $text = get_field(‘news’); if ( ” != $text ) { $start = strpos($text, ‘<p>’); // Locate the first paragraph tag $end = strpos($text, ‘</p>’, $start); // Locate the first … Read more

truncate post with gallery tag

Use strip_shortcodes as well. That should remove the shortcodes from the content. A couple of notes: Your code seems to be doing some things that I don’t understand. For example, you run the the_content filter on your content which adds markup, only to run strip_tags later, which removes (at least some of) that markup. strip_tags … Read more

How can I add in post’s the text “No content”

add_filter( ‘the_content’, ‘check_empty_postcontent’, 0, 99 ); // filter post content add_filter( ‘the_excerpt’, ‘check_empty_postcontent’, 0, 99 ); // filter excerpt content function check_empty_postcontent( $content ) { global $post; $post_type = get_post_type( $post->ID ); return ( empty( $content ) && ‘seriale’ === strtolower( $post_type ) ) ? ‘No content available’ : $content; } There are a lot … Read more

WordPress truncate posts question (plugin related)

This is a rather sloppily coded plugin, unfortunately. However, to answer your questions: Replace the function gopiplus_clean with this function gopiplus_clean( $excerpt, $length = 0 ) { $string = strip_tags( str_replace( ‘[…]’, ‘…’, $excerpt ) ); if ( $length > 0 ) { $words_array = preg_split( “/[\n\r\t ]+/”, $excerpt, $length + 1, PREG_SPLIT_NO_EMPTY ); $words … Read more

Manual excerpt length on recent posts slider

The line below the one you edited computes the edited words based on the height and width of the slider box. The value you added is changed on the next line. Avoid editing the plugin file. Next time you update the plugin your changes will be lost. You should be able to change the Excerpt … Read more

first excerpt fine, subsequent post excerpts shift to the right instead of displaying vertically [closed]

I can’t add comments yet, but do you get what Milo is saying? Just look at this section and it is as if there are no closing or tags for the classes post and post-preview. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class=”post-image”> <?php if ( has_post_thumbnail() ) … Read more

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