← Back
Editing: single.php
<?php include 'blocks/head.php'; include 'blocks/header.php'; ?> <head> <link rel="stylesheet" type="text/css" href="/wp-content/themes/theme_bretas/assets/css/style.css" /> <link rel="stylesheet" type="text/css" href="/wp-content/themes/theme_bretas/assets/css/post.css" /> <script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script> </head> <body> <?php /* <div class="banner-upper-home"> <div class="banner-upper-home-box"> <p>Publicidade</p> <a class="banner-upper-home-link" href="<?php echo esc_url(get_option('custom_banner_link')); ?>"> <img class="banner-upper-home-img" src="<?php echo esc_url(get_option('custom_banner_image')); ?>" alt="Banner"> </a> <p>Publicidade</p> </div> </div> */ ?> <main> <br> <div class="box-post-category"> <span class="post-category"> <?php $categories = get_the_category(); echo !empty($categories) ? $categories[0]->name : ''; ?> </span> </div> <div class="title-posts-container"> <h1 style="font-weight:600; line-height: 40px"><?php the_title(); ?></h1> </div> <div class="box-compartilhar"> <div class="infos-post"> <span style="width: 145px;height:42px;"> <p style="color:#000; font-size: 12px"><?php echo get_the_date(); ?></p> </span> <span style="margin: 0 10px;"> | </span> <?php echo exibir_tempo_de_leitura(); ?> </div> <div class="botoes-compartilhar"> <H3> Compartilhe: </H3> <a href="https://twitter.com/intent/tweet?url=<?php echo urlencode(get_permalink()); ?>" target="_blank" rel="noopener noreferrer" class="botao-compartilhar"><img src="<?php include 'host.php'; echo $host ?>/wp-content/uploads/icons/twitterx.png" class="btn-social"></a> <a href="https://api.whatsapp.com/send?text=<?php echo urlencode(get_permalink()); ?>" data-action="share/whatsapp/share" target="_blank" rel="noopener noreferrer" class="botao-compartilhar"><img src="<?php include 'host.php'; echo $host ?>/wp-content/uploads/icons/whatsapp.png" class="btn-social"></a> <a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo urlencode(get_permalink()); ?>" target="_blank" rel="noopener noreferrer" class="botao-compartilhar"><img src="<?php include 'host.php'; echo $host ?>/wp-content/uploads/icons/facebook.png" class="btn-social"></a> </div> </div> <div class="post-img" style="width:100%;display:flex;justify-content:center;margin:10px 0;"> <img src="<?php echo get_the_post_thumbnail_url(); ?>" alt="Imagem Destacada" class="imagem_destacada" /> </div> <div class="container-menu-hamburguer"> <div class="menu-hamburguer"> <div class="icon-hamburguer" onclick="toggleMenu()">☰</div> <div class="menu"> <p style="font-size:large;font-weight:700">Aqui você vai ler sobre:</p> <?php global $post; if ($post) { $post_content = $post->post_content; $pattern = '/<h([1-6])([^>]*)>(.*?)<\/h\1>/i'; preg_match_all($pattern, $post_content, $matches, PREG_SET_ORDER); if (!empty($matches)) { echo '<ul style="list-style-type: disc;padding-left:20px;">'; $used_ids = []; // garante IDs únicos foreach ($matches as $match) { $heading_level = $match[1]; $heading_text = wp_strip_all_tags($match[3]); // cria ID único $id = sanitize_title($heading_text); $original_id = $id; $count = 2; while (in_array($id, $used_ids)) { $id = $original_id . '-' . $count; $count++; } $used_ids[] = $id; // substitui no conteúdo apenas a ocorrência atual $heading_with_id = sprintf( '<h%s id="%s"%s>%s</h%s>', $heading_level, esc_attr($id), $match[2], $match[3], $heading_level ); $post_content = preg_replace('/' . preg_quote($match[0], '/') . '/', $heading_with_id, $post_content, 1); // link do índice echo '<li style="margin-bottom:10px;"> <a href="#' . esc_attr($id) . '" style="text-decoration:none;cursor:pointer;color:#000;">' . esc_html($heading_text) . '</a> </li>'; } echo '</ul>'; } } ?> </div> </div> </div> <script> function toggleMenu() { var menu = document.querySelector('.menu'); menu.style.display = (menu.style.display === 'block' || menu.style.display === '') ? 'none' : 'block'; } </script> </div> </div> <div class="container-content"> <div class="post-content"> <?php echo apply_filters('the_content', $post_content); ?> </div> </div> </main> <div class="related-posts-container"> <div class="related-posts-header"> <h2 text-align="left; width 1000px;">Você vai gostar também:</h2> <span style="display: inline-block; width: 850px; margin-right: 79px; border-top: 4px solid black;"></span> </div> </div> <?php $tags = get_the_tags(); if (!empty($tags)) { $tag_ids = array(); foreach ($tags as $tag) { $tag_ids[] = $tag->term_id; } $args = array( 'tag__in' => $tag_ids, 'post__not_in' => array(get_the_ID()), 'posts_per_page' => 3, 'orderby' => 'rand', ); $related_posts = new WP_Query($args); if ($related_posts->have_posts()) { echo '<div class="related-posts-row">'; while ($related_posts->have_posts()): $related_posts->the_post(); ?> <a class="related-post-link" href="<?php echo esc_url(get_permalink()); ?>" style="text-decoration: none;"> <div class="related-post-column" style="width: 100%;box-sizing: border-box;margin-bottom: 20px;display: flex;flex-direction: column;align-items: center;"> <div class="related-post-thumbnail"> <img src="<?php echo get_the_post_thumbnail_url(); ?>" alt="<?php echo esc_html(get_the_title()); ?>" class="related-img"> </div> <h3 id="subtitulo" align="center"><?php echo esc_html(get_the_title()); ?></h3> </div> </a> <?php endwhile; echo '</div>'; } wp_reset_postdata(); } ?> </div> </main> <?php include(get_template_directory() . '/blocks/footer.php'); ?>
Save File
Cancel