G
G
Grisha Nikolsky2015-12-19 23:15:03
WordPress
Grisha Nikolsky, 2015-12-19 23:15:03

How to display custom post type?

Greetings. Created a custom post type - "tour".
In sidebar.php, I only made the display of the titles of these posts. Everything is working. Here is what the title output looks like:

<a href="<?php the_permalink() ?>"> <?php echo $title[0]; ?> </a>
If anything, $title[0] contains custom meta field data. This part works great.
But when I click on the link, it throws me into index.php. This is what my single-tour.php looks like:
<?php

get_header();

?>

<div class="container under_head">
  <div class="row">
    <div class="col-md-8">
      <?php
      if ( have_posts() )
      {
        while (have_posts())
        {
          the_post(); ?>
          <div class="content">
            <h3>
              <?php the_title(); ?>
            </h3>

            <?php
              $date = get_post_meta( get_the_ID(), 'tour_date' );
            ?>
            <strong>Дата: </strong><?php echo $date[0] ?>

          </div>
          <?php
        }
      }
      ?>
      <hr class="separator hidden-lg hidden-md">
    </div>

    <div class="col-md-4">
      <div class="sidebar">
        <?php get_sidebar(); ?>
      </div>
    </div>
  </div>
</div>

I reviewed a bunch of tutorials, it was done in exactly the same way. I've been struggling with this case for 3 hours already.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WP Panda, 2015-12-20
@VoxelGod

Resave cnc rules

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question