1

I designed a template for WordPress, I've only encountered a problem in one section. How can I create a post to display single.php for my site?

Thanks!

5
  • What do you mean when saying "Post Display"? Commented Aug 21, 2018 at 7:58
  • Hi @morteza Ahmadi Are you using default post type or custom post post type.. Commented Aug 21, 2018 at 8:01
  • @AdirRatzon that page show posts contents in single page . Commented Aug 21, 2018 at 8:14
  • @YogeshGarg Default post type .. i want to show 1 post contents in single page . Commented Aug 21, 2018 at 8:15
  • @MortezaAhmadi every theme has single.php file by default. You can use that file. Even WordPress will automatically use single.php file of current theme. you can make changes in that file. Commented Aug 21, 2018 at 9:13

2 Answers 2

1

Your issue is a trivial thing. In order to show your blog/website posts, you need to call the_post() function inside of a loop.

As long there are posts in your blog, the_post() should render a response. Take a look at Twenty_Fourteen single.php default template in order to get a better understanding of how things should be.

Sign up to request clarification or add additional context in comments.

Comments

1
  1. Make a back up copy of single.php, call this single-original.php.

  2. Open single.php file. Delete the contents of single.php and place the below code in it.

    <?php
     $post = $wp_query->post;
     if ( in_category('2') ) {
      include(TEMPLATEPATH . '/single_new.php');
    } else {
       include(TEMPLATEPATH . '/single_new1.php');
      }
    ?>
    
  3. Open single-original.php and choose File > Save As and call this file single_new.php. Choose File > Save As again and call this file single_new1.php.

  4. Upload single.php, single_new.php and single_new1.php as well as style.css, if you made changes in this.

  5. Refresh your web page and click on one of the post titles in the category for which you are using single_new1.php.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.