Site icon Hip-Hop Website Design and Development

Get and Trim Full Publish Content material in WP Question

Easy job, but it surely is not working:

<?php 
$content material = apply_filters( 'the_content', get_the_content() );
$contentWithoutHTML = wp_strip_all_tags($content material);
$pos = strpos($contentWithoutHTML, " ", 100);
$contentFinal = substr($contentWithoutHTML,0,$pos ); 
echo $contentFinal . "...";
?>

My put up is manner over 100 characters lengthy (with areas), and but I get strpos(): Offset not contained in string error, which leads me to consider it is not really pulling the whole content material string. However I utilized filters like I consider I ought to… please help. Additionally typically even when I get no offset error I simply get ... although once more, over 100 characters with areas… though typically it really works. Why the inconsistency?

That is in a WP_Query loop through which most of them work, however a few of them don’t… so I’m fairly positive it’s being fed a string as a result of I see it occurring to the opposite posts within the loop…

Full Loop:

<?php
$args = array(
    'orderby' => 'ID',
    'order' => 'ASC',
    'posts_per_page' => 7,
    'meta_query' => array(
        array(
            'key' => '_thumbnail_id'
        )
    )
);
$question = new WP_Query($args);
whereas ($query->have_posts()):
    $query->the_post();
?>
                            <div class="articleboxs boxs">
                                <div class="col-sm-4 noleft">
                                    <div class="aricleleft boxs">
                                      <?php the_post_thumbnail('medium', array(
        'class' => 'img-responsive'
    )) ?>  
                                    </div>
                                </div>
                                <div class="col-sm-8 noright">
                                    <div class="aricleright boxs">
                                        <div class="boxs">
                                             <a href="<?php echo get_permalink(); ?>"><h2 class="heading font_Libre"><?php the_title(); ?></h2></a>
                                                <?php
    $content material = apply_filters('the_content', get_the_content('', true));
    print_r($content material);
    $contentWithoutHTML = wp_strip_all_tags($content material);
    $pos = strpos($contentWithoutHTML, " ", 100);
    $contentFinal = substr($contentWithoutHTML, 0, $pos);
?>
                                 <p class="font_Roboto"><?php echo $contentFinal . "..."; ?></p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                          <?php
endwhile;
wp_reset_postdata();
?>