1

I'm very new to wordpress theme developing and just started to make a one with bootstrap 3.I'm running wordpress on my localhost on nginx webserver.I created index.php file and make posts listed on it with read more buttons and linked their titles to post's permalinks and created the single.php also.It also working fine but i feel there's something wrong with my codes.

My post's permalinks looks like this.Always showing index.php

http://www.blog.dev/index.php/%postname

so i change post's permalinks to custom and removed that "index.php". After that my signle.php doesn't working. I mean it gives me a error 404.

Here's my single.php

<!-- Including Header -->
<?php get_header(); ?>

<!-- Post Cover -->
<div id="postCover" class="container-fluid"></div>
<div id="postContainer" class="container">
    <div class="col-md-2"></div>
    <div class="col-md-8">
        <div class="panel panel-default">
            <div class="panel-heading">
                <?php the_title(); ?>
            </div>
            <div class="panel-body">
                <?php
                    if ( has_post_thumbnail() ) {
                        the_post_thumbnail('post-thumbnail', array( 'class' => "img-responsive"));
                    }
                ?>
                <div id="posDetailsContainer" class="container-fluid text-left">
                    <span>
                        <i class="fa fa-calendar"></i>&nbsp;
                        Posted on <?php the_time('M'); ?>&nbsp;&nbsp;<?php the_time('j'); ?>&nbsp;&nbsp;<?php the_time('Y'); ?>
                    </span>
                    <span>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <i class="fa fa-comments-o"></i>&nbsp;
                        <?php comments_number( 'No Comments', '1 Comment', '% Comments' ); ?>
                    </span>
                </div>

                <!-- Post Content Display -->
                <div id="postContent" class="container-fluid">
                    <?php
                        if ( have_posts() ) : while ( have_posts() ) : the_post();
                            the_content();
                            endwhile;
                        endif;
                    ?>
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-2"></div>
</div>

How to fix this ?

Thanks ! Srivin Prabhash

3
  • How did you change permalinks? In the permalinks settings? Commented Mar 31, 2016 at 7:47
  • @dingo-d yes sir.I make the permalinks customs and removed that index.php part from it. Thanks ! Commented Mar 31, 2016 at 7:51
  • how does your .htaccess file look like? Please paste it. Does .htaccess file even exist in your root folder of wordpress CMS? Commented Mar 31, 2016 at 8:26

2 Answers 2

1

I think you have done some mistake in index.php. Put this code in your index.php file.

    if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <h4><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h4>
    <h5>Posted By :  <?php the_author(); ?> | Date : <?php echo the_date('d-m-y'); ?></h5>
    <p><?php  the_excerpt(); ?></p>
    <a href="<?php the_permalink();?>"> Read more </a>
    <?php endwhile; ?>
    <?php endif; ?>
  <?php wp_reset_query(); ?>    

Still if you face this problem remove your .htaccess file from root directory and change permalink setting.Tack backup before delete .htaccess file.

I hope this will work for you.

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

Comments

0

Add .htaccess file on root folder and paste this code inside the file

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

and then go to setting->permalink and select postname. it will works

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.