• PixelRelish

    (@pixelrelish)


    I use the below to display the latest blog posts on a static home page. The post_content unfortunately is including a line of video embed shortcode; I want to exclude shortcodes from the content feed (but not from the index page entirely: I have the video showing up in a different column).

    I found instruction on how to strip out the shortcode, only I do not know (and have not been able to find in hours of searching) the php syntax. Could someone help me?

    Live site is http://krishanti.com. You’ll see the error in the LATEST POST content paragraph (opens the paragraph).

    Thanks!

    Not bothering to include the full surrounding html.

    <!--LATEST POST-->
                	 <?php $the_query = new WP_Query( 'showposts=1' ); ?>
                          <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
                            <div class="row">
                            	<div class="medium-7 medium-push-5 columns">
                                    <h5>LATEST POST</h5>
                                    <h2 class="margTzero"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
                                    <p class="margBhalf"><?php echo substr(strip_tags($post->post_content), 0, 700);?>...</p>
                                    <h5 class="margTzero"><a href="<?php the_permalink() ?>">continue reading...</a></h5>
                                </div>
                                <div class="medium-5 medium-pull-7 columns bodyfont2 padTtwo">
    								<div class="row">
                                            <div class="small-12 columns">
                                                    <?php
                                                        $thumbnails = get_posts( 'numberposts=1' );
                                                             foreach ( $thumbnails as $thumbnail ) {
                                                                 if ( has_post_thumbnail( $thumbnail->ID ) ) {
                                                                     echo '<a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">';
                                                                     echo get_the_post_thumbnail( $thumbnail->ID, 'thumbnail' );
                                                                     echo '</a>';
                                                                 }
                                                             }
                                                ?>
                                        </div></div>

The topic ‘Remove shortcode and tags from latest post feed’ is closed to new replies.