• Resolved Maiskolben

    (@maiskolben)


    Hello,

    is it possible to make the_content(‘more…’); not show images and text-formats, like the_excerpt(); do?

    Greetings,

    Maiskolben

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Maiskolben

    (@maiskolben)

    nobody an idea?

    are we in a hurry?

    you would probably need to do a bit of programming;
    looking into the code of ‘get_the_content()’ https://phpxref.ftwr.co.uk/wordpress/wp-includes/post-template.php.source.html#l174 might get you some ideas, as to how wordpress determines the position of the ‘more’ tag; strip_tags() could help to get rid of the formatting that you don’t want; https://www.w3schools.com/php/func_string_strip_tags.asp
    apply_filters(‘the_excerpt’,$string) might also be worth trying; etc.

    Thread Starter Maiskolben

    (@maiskolben)

    thank you for answering!
    I found this piece of code for rewriting the content of get_the_content() to a new function, so that I can use a preg_match() to take only the img-tag…

    function deretwaswenigercontent($more_link_text = 'mehr »', $stripteaser = 0, $more_file = '') {
     $content = get_the_content($more_link_text, $stripteaser, $more_file);
     $content = apply_filters('the_content', $content);
     $content = str_replace(']]>', ']]>', $content);
      return $content;
    }

    and for the archive.php (or whereever you want to display the_content() without images), you can use this line..

    <?php echo preg_replace('/<img[^>]+./','', deretwaswenigercontent()); ?>

    Thank you for your advice!

    Maiskolben

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘the_content(‘more…’);’ is closed to new replies.