WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need a duplicate of index.php, but slightly modified. I added a "vote it up" plugin. So, I want the user to select how to display posts - by new or by popular. I know what to add to second index.php, but how to create a second index.php, thats the problem.

share|improve this question
up vote 0 down vote accepted

Elaborating on Rachel Baker's answer:

Copy the index.php file and name it something like popular.php. At the very top, paste the following:

Template Name: Posts by Popular

Now, go in to the WordPress admin and create a new page, called something like "By Popular". On the right-hand side, select the "Posts by Popular" template where it says "Template" (screenshot). Publish the page, and when you view it you should see your new page.

Create a link to this page in the nav menu or wherever, and then your users will be able to access the new page.

share|improve this answer
This was really easy to do, but actually when I apply the template vote it up plugin is not working correctly even before adding changes. So, I will have to get rid of this idea.. – Domante Stirbyte Aug 28 '11 at 15:46

You can create a new page, using a modified template file - and send users to that page if they choose to display posts "by popular"

share|improve this answer
modified template file? A little advice where to start with this? – Domante Stirbyte Aug 28 '11 at 8:11

When i do this kinds of modification i always use child theme Because its the easy way to doing it. And if i mess the child theme up i can just copy files form the main theme anytime.

If you never tried the child theme. This might be the right time for you. ;) Just make a child theme copy the index.php file form original theme and place it to the child theme directory and edit.

share|improve this answer
Can you help me with understanding of this? So, I create a new folder in my themes folder, put style.css and my modified index.php. The question is how to make wordpress understand when to switch index.php? – Domante Stirbyte Aug 28 '11 at 8:33
@Sisir I believe OP is asking for a way how to let users switch the two different views. Therefore child theme offers a little help for this usecase. Aside from that, yes, using a child themes really is a good idea. – Michal Mau Aug 28 '11 at 9:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.