janochen
  • 0
Мастер

Добавление некоторого HTML-кода в сообщения не работает, но работает, если он добавляется непосредственно в файл?

  • 0

У меня был код в файле шаблона. Когда я вставил его с панели сообщений бэкэнда (вкладка HTML) в качестве сообщения и извлек его как пользовательский цикл, код не выводился должным образом.

Какие-либо предложения?

Добавляем их как посты:

<?php
/**
 * Template Name: Lyrics Page
 * @package WordPress
 * @subpackage Prominent
 * @since Prominent 1.0
 */
get_header(); ?>
<div id="tagline">
    <div class="container">
        <?php // Run main loop (The Loop). ?>
        <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
        <div class="content0">
        </div>
        <?php endwhile; ?>
    </div><!-- .container -->
</div><!-- #content-bottom -->
<div id="content">
    <div class="container">
        <div id="mainbar">
            <div id="accordions-top">
            <?php $custom_posts = new WP_Query(); ?>
            <?php $custom_posts->query('category_name=Lyrics'); ?>
            <?php while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?>
                <?php the_content(); ?>
            <?php endwhile; ?>
            </div>
        </div><!-- #mainbar -->
        <?php get_sidebar(); ?>
    </div><!-- .container -->
</div><!-- #content-bottom -->
<?php get_footer(); ?>

Непосредственно в файле:

<?php
/**
 * Template Name: Lyrics Page
 * @package WordPress
 * @subpackage Prominent
 * @since Prominent 1.0
 */
get_header(); ?>
<div id="tagline">
    <div class="container">
        <?php // Run main loop (The Loop). ?>
        <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
        <div class="content0">
            <?php the_content(); ?>
        </div>
        <?php endwhile; ?>
    </div><!-- .container -->
</div><!-- #content-bottom -->
<div id="content">
    <div class="container">
        <div id="mainbar">
            <div id="accordions-top">
                            <div class="basic" style="float:left; margin-left: 2em;" id="list1e">
                        <a>There is one obvious advantage:</a>
                        <div>
                            <p>
                                You've seen it coming!<br/>
                                Buy now and get nothing for free!<br/>

                                Well, at least no free beer. Perhaps a bear,<br/>
                                if you can afford it.
                            </p>
                        </div>
                        <a>Now that you've got...</a>
                        <div>
                            <p>
                                your bear, you have to admit it!<br/>

                                No, we aren't selling bears.
                            </p>
                        </div>
                        <a>Rent one bear, ...</a>
                        <div>
                            <p>
                                get two for three beer.
                            </p>
                            <p>

                                And now, for something completely different.<br/>
                                And now, for something completely different.<br/>
                                And now, for something completely different.<br/>
                                And now, for something completely different.<br/>
                                And now, for something completely different.<br/>
                                And now, for something completely different.<br/>

                                And now, for something completely different.<br/>
                                And now, for something completely different.<br/>
                                Period.
                            </p>
                        </div>
                </div>
            </div>
        </div><!-- #mainbar -->
        <?php get_sidebar(); ?>
    </div><!-- .container -->
</div><!-- #content-bottom -->
<?php get_footer(); ?>

Вывод поста при добавлении через админку:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux/x86 (vers 11 February 2007), see www.w3.org" />

  <title></title>
</head>

<body>
  <div id="content">
    <div class="container">
      <div id="mainbar">
        <div id="accordions-top">
          <div class="basic" style="float:left; margin-left: 2em;" id="list1e">
            <a>There is one obvious advantage:</a>

            <div>
              <p>You&rsquo;ve seen it coming!<br />
              <br />
              Buy now and get nothing for free!<br /></p>

              <p>Well, at least no free beer. Perhaps a bear,<br />
              <br />
              if you can afford it.</p>
            </div>

            <p><a>Now that you&rsquo;ve got&hellip;</a></p>

            <div>
              <p>your bear, you have to admit it!<br /></p>

              <p>No, we aren&rsquo;t selling bears.</p>
            </div>

            <p><a>Rent one bear, &hellip;</a></p>

            <div>
              <p>get two for three beer.</p>

              <p>And now, for something completely different.<br />
              <br />
              And now, for something completely different.<br />
              <br />
              And now, for something completely different.<br />
              <br />
              And now, for something completely different.<br />
              <br />
              And now, for something completely different.<br />
              <br />
              And now, for something completely different.<br /></p>

              <p>And now, for something completely different.<br />
              <br />
              And now, for something completely different.<br />
              <br />
              Period.</p>
            </div>
          </div>
        </div>
      </div><!-- #mainbar ==ý-->
    </div>
  </div>
</body>
</html>
Share
  1. Наконец-то понял, что мне нужно это:

    remove_filter('the_content', 'wpautop');

    • 0

Оставить ответ

You must login to add an answer.