Search code examples
phpwordpresswysiwyg

WordPress: Own content after every more-tag


I want to display content everytime I'm using a more-tag in the editor. I found a solution to do this for the first more-tag with this code:

<?php if ($pos=strpos($post->post_content, '<!--more-->')): ?>
<?php $more = 0; the_content(''); ?>
<div>CONTENT HERE</div>
<?php $more = 1; the_content('', true); ?>
<?php else : the_content(); endif; ?>

Is there any way to do this for every more-tag in the content?


Solution

  • What you think about this?

    <?php 
    $contenido="Lorem ipsum dolor sit amet, his id porro lucilius theophrastus. -mas- Eum labitur voluptaria te, magna veniam civibus -mas- ad mei. An per ornatus officiis quaerendum, sonet timeam ad eam, nec an vidisse discere intellegam. Iusto habemus reprimique an nec.";
    
    $contenidoExploded=explode('-mas-',$contenido);
    
    if(count($contenidoExploded)>1){
        foreach($contenidoExploded as $p){
            echo $p.'</p>';   
        }
    }else{
        echo $contenido;
    }
    

    It works for you?