Suporte » Problemas no funcionamento » Custom field não exibe

  • Resolvido thiibs

    (@thiibs)


    Estou tentando inserir os custom fields em certa parte do template porém não funciona… se eu mudo a div de lugar ele aparece, mas onde deve aparecer não…
    Segue o código:

    <div id="content" role="main">
    <?php the_post(); ?>
    <!-- ### BANNER ### -->
    <div id="banner"> <img src="<?php echo get_post_meta($post->ID, 'ImagemURL', TRUE); ?>" alt="" title="<? the_title() ?>" /> </div>
    <!-- ### FIM BANNER ### -->
    <!-- ### VÍDEO ### -->
    <?php $YoutubeId = get_post_meta($post->ID, "YoutubeId", true); ?>
    <?php if($YoutubeId !== '') { ?>
    <div class="video_style">
      <iframe width="445" height="253" src="http://www.youtube.com/embed/<?php echo $YoutubeId; ?>" frameborder="0" allowfullscreen></iframe>
      <div id="col-dir">
        <h1><?php echo get_post_meta($post->ID, 'TituloVideo', TRUE); ?></h1>
        <p><?php echo get_post_meta($post->ID, 'DescricaoVideo', TRUE); ?></p>
        <br />
        <h2>Cadastre-se</h2>
        <div id="desc-cad">
          <p>Ut wisi enim ad minim veniam, quis nostrud exerci.</p>
          <span class="news">
          <input type="text" value name="email" size="20"/>
          <input class="send" type="submit" value="ok">
          </span> </div>
        <div id="bottom">
          <div id="ultimas">
            <h1 style="padding-top: 9px;">Últimas notícias</h1>
            <ul>
              <?php query_posts('showposts=2'); ?>
              <?php if (is_home()) { query_posts("category_name=noticias"); } ?>
              <?php while (have_posts()) : the_post(); ?>
              <li><a href="<?php the_permalink() ?>">
                <h2>
                  <?php the_time('d/m') ?>
                  <?php the_title(); ?>
                </h2>
                </a>
                <?php the_excerpt(); ?>
              </li>
              <?php endwhile;?>
            </ul>
          </div>
          <div id="dica">
            <h1>Dica saudável</h1>
            <ul>
              <?php query_posts('showposts=1'); ?>
              <?php if (is_home()) { query_posts("category_name=dica-saudavel"); } ?>
              <?php while (have_posts()) : the_post(); ?>
              <li>
                <h2><a href="<?php the_permalink() ?>">
                  <?php the_title(); ?>
                  </a> </h2>
                <?php the_excerpt(); ?>
              </li>
              <?php endwhile;?>
            </ul>
            <h3><a href="#">Mais aqui</a></h3>
          </div>
          <div id="enquete">
            <h1>Enquete</h1>
            <br />
            <p><?php echo get_post_meta($post->ID, 'CodigoEnquete', TRUE); ?></p>
          </div>
         </div>
        <?php } ?>

    Se eu coloco CodigoEnquete embaixo de DescricaoVideo, ele funciona. Porém, onde ele está atualmente, não exibe nada, e não mostra nenhum erro.
    Sabem me dizer o que está errado?
    Obrigado!

A visualizar 1 resposta (de um total de 1)
  • O seu get_post_meta($post->ID, 'CodigoEnquete', TRUE); precisa de estar dentro do loop, ou seja antes do endwhile;. Ponha o endwhile; depois do get_post_meta().

    Entre em contacto comigo se precisar de ajuda,
    PedroWP.com – Programador & Ajuda WordPress

A visualizar 1 resposta (de um total de 1)
  • O tópico ‘Custom field não exibe’ está fechado a novas respostas.