1

On the index page I want to show projects. Each project has a detail. When clicked on the permalink on the index page it should open detail page. But it doesn't do so. This is the code:

<a href="<?php echo get_the_permalink(); ?>"  title="more">
  <div class="work-item branding ui-ux">
     <div class="work-detail">
        <a href="<?php the_permalink(); ?>">
           <img src="<?php echo get_the_post_thumbnail_url() ?>" alt="">
               <div class="work-info">
                   <div class="centrize">
                      <div class="v-center">
                         <h3><?php echo the_title();?></h3>
                           <p><?php the_excerpt(); ?></p>
                      </div>
                   </div>
               </div>
        </a>
     </div>
  </div>
</a>
<?php if (have_posts()){ ?>
<section class="page-title parallax-section">
    <div class="row-parallax-bg">
        <div class="parallax-wrapper">
            <div class="parallax-bg">
                <img src="images/bg-image-54.jpg" alt="">
            </div>
        </div>
        <div class="parallax-overlay"></div>
    </div>
    <div class="centrize">
        <div class="v-center">
            <div class="container">
                <div class="single-post-info">
                    <h6><span><i class="hc-clock"></i>تاریخ پست</span><span class="post-time">22<?php the_date('D/M/Y') ?></span><span> در <a href="#"><?php the_category(); ?></a></span></h6>
                    <div class="title text-center">
                        <h1>لورم ایپسوم متن ساختگی با </h1>
                    </div>
                    <div class="post-author">
                        <img src="images/testimonial-2.jpg" alt=""><a href="#"><?php the_modified_author(); ?></a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<?php } ?>
<section>

When I click on picture or links a new link creates: "http://localhost/wordpress/faradars/project/lorem ipsum" and it refers to index page. Can anyone help me to fix it?

  • So, the_title and get_the_post_tumbnail_url work, but the_permalink does not? That is not normal behaviour. Possibly a plugin is interfering. Switch them all off and see if the behaviour changes. – cjbj May 23 at 16:02
  • If http://localhost/wordpress/faradars/project/lorem ipsum Is the correct URL for the post, then there’s nothing wrong with the_permalink(). That function just gives you the URL, and has nothing to do which what happens when you go to it. It sounds like you’re missing a single-project.php template and have incorrectly used a custom query on index.php. What templates exist in your theme, and what does index.php look like? – Jacob Peattie May 23 at 16:14
  • it looks unusual that the permalink has a space in the post title part; I would expect it to be a hyphen; like http://localhost/wordpress/faradars/project/lorem-ipsum - are you using anything to change the default link sanitation? – Michael May 23 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.