Untitled
unknown
plain_text
2 years ago
2.4 kB
12
Indexable
<?php get_header(); // Verifica se ci sono post disponibili if (have_posts()) { // Ciclo sui post while (have_posts()) { the_post(); // Mostra il titolo del post the_title('<h1>', '</h1>'); // Mostra il contenuto del post $content = get_the_content(); // Dividi il contenuto in paragrafi $paragraphs = explode('</p>', $content); // Verifica il numero di paragrafi $num_paragraphs = count($paragraphs); // Verifica se ci sono almeno due paragrafi if ($num_paragraphs >= 2) { // Inserisci la call to action dopo il secondo paragrafo $content_with_cta = $paragraphs[0] . '</p>' . $paragraphs[1] . '</p>'; $content_with_cta .= '<div style="background-color: blue; height: 200px;">'; $content_with_cta .= '<a href="https://ansa.it" target="_blank" style="display: flex; align-items: center; justify-content: center; height: 100%; text-decoration: none;">'; $content_with_cta .= '<button style="padding: 10px 20px; background-color: #00ff00; color: #fff; border: none;">Registrati qui</button>'; $content_with_cta .= '</a>'; $content_with_cta .= '</div>'; $content_with_cta .= implode('</p>', array_slice($paragraphs, 2)); // Stampa il contenuto con la call to action echo $content_with_cta; } else { // Inserisci la call to action sotto il primo paragrafo $content_with_cta = $paragraphs[0] . '</p>'; $content_with_cta .= '<div style="background-color: blue; height: 200px;">'; $content_with_cta .= '<a href="https://ansa.it" target="_blank" style="display: flex; align-items: center; justify-content: center; height: 100%; text-decoration: none;">'; $content_with_cta .= '<button style="padding: 10px 20px; background-color: #00ff00; color: #fff; border: none;">Registrati qui</button>'; $content_with_cta .= '</a>'; $content_with_cta .= '</div>'; if ($num_paragraphs > 1) { $content_with_cta .= implode('</p>', array_slice($paragraphs, 1)); } // Stampa il contenuto con la call to action echo $content_with_cta; } } } else { // Messaggio nel caso in cui non ci siano post disponibili echo 'Nessun post trovato.'; } get_footer(); ?>
Editor is loading...