Trying to edit archive.php to only show post extract, with featured image

To replace the full content with the excerpt, change <?php the_content( ‘<em>Continue reading &rarr;</em>’ ); ?> To <?php the_excerpt(); ?> To display the featured image use this: <?php the_post_thumbnail( ‘single-post-thumbnail’ ); ?> Note: Make sure you have this next snippet somewhere in your theme’s functions.php file //add theme support for post thumbnails add_theme_support( ‘post-thumbnails’ );

How to disable the_excerpt from one post

First of all, WordPress already includes a function for displaying excerpts: the_excerpt() Secondly, your second piece of code isn’t actually displaying anything. You need to use the echo statement for displaying text on the page. However, WordPress provides functions that actually display the content and excerpt on the page: the_content() and the_excerpt(), respectively. if( in_array( … Read more

apply_filters(‘get_the_content’, $content) + Except

If you mean you would like to create an excerpt automatically from the post’s content, you could use wp_trim_words. $auto_excerpt = apply_filters( ‘the_excerpt’, wp_trim_words( $content, 30, “…” ) ); ?> Where 30 is the number of words you wish the excerpt to be at most, and the ellipsis “…” is what will appear at the … Read more

stripping tags from excerpt in WordPress is not working

the_excerpt() automatically echoes the excerpt text. What you need is get_the_excerpt(): <a href=”https://wordpress.stackexchange.com/questions/108530/<?php the_permalink() ?>” title=”<?php echo strip_tags( get_the_excerpt() ); ?>”> However, it probably won’t strip out ellipses (…) since they’re HTML entities, not tags.

Read more to open external link

You just need to add target=”_blank” to the anchor tag. function remove_more_link_scroll( $link ) { $link = str_replace(‘>’,’ target=”_blank”>’, $link); return $link; } add_filter( ‘the_content_more_link’, ‘remove_more_link_scroll’ ); I feel compelled to state that I consider forcing new tabs/windows to be very unfriendly behavior, and if you search the web you will see that I am … Read more

Displaying post excerpt using wpdb query

I guess your post_excerpt field is empty and you need to generate an excerpt from the post_content. I agree with @t f using the general WP_Query(), have_post(), the_post(), the_excerpt() method of looping. I just want to mention that WordPress comes with the handy wp_trim_words() function that can be used to shorten text strings. Outside the … Read more

Problem with showing featured image

Use an is_single() condition to ensure the thumbnail isn’t added on archive pages. You should also be using get_the_post_thumbnail and prepending it to $content, rather than just echo’ing it out: function put_thumbnail_in_posting( $content ) { if ( is_single() && has_post_thumbnail() && get_post_type() == ‘post’ ) { $thumbnail = get_the_post_thumbnail( null, ”, array( ‘style’ => implode( … Read more

get video from content

Assuming your content is in the variable $content you would begin by removing all html tags using wp_strip_all_tags: $new_content = wp_strip_all_tags( $content ); Then you will want to trim that to 200 characters using substr: $new_content = substr( $new_content, 0, 200 ); To retrieve the YouTube video, you’ll need to use preg_match: preg_match( ‘/(<iframe.*?src=”https://wordpress.stackexchange.com/questions/154352/(.*?youtube.*?)”.*?<\/iframe>)/’, $html, … Read more

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