WordPress.org

Ready to get started?Download WordPress

Forums

Adding php files to Theme (8 posts)

  1. ScottHYoung
    Member
    Posted 8 years ago #

    I'm in the last few stages of redoing my wordpress theme and I encountered some difficulty trying to redesign my archives page.

    Instead of the classic excerpt archives I want to display a page that lists all of the titles for every single post I've made in a long list of links. I thought I'd do this by modifying the wordpress loop used for the main index but instead of posting the content just displaying the title and permalink.

    Unfortunately this php code would be a deviation from any template file I have on hand. I created this file to be called archives.php with my template. Now my only problem. How do I create a page in my blog that will use this file?

    I couldn't find any clues to how wordpress selects these php files to be displayed so I'm not sure how I would create a new page that uses a different format. Any help would be greatly appreciated.

  2. maerk
    Member
    Posted 8 years ago #

    <?php wp_get_archives('type=postbypost'); ?> will list all your posts in an unordered list.

  3. Ryan Fitzer
    Member
    Posted 8 years ago #

    Make the template page with the custom loop you want with this at the top and put in your theme's folder:

    <?php
    /*
    Template Name: Place name here
    */
    ?>

    Then in your admin create a page and in the right sidebar specify your new template page for the new page your creating. It's nice and easy.

  4. ScottHYoung
    Member
    Posted 8 years ago #

    Sorry ryanfitzer, I'm not sure how to specify a template page for my new page I'm creating. Could you be a little more descriptive?

    For the first part, placing <?php /* TemplateName */ ?> do you mean just place my file in the themes folder? You have a php command here that seems to be commented out, is that significant or do I have to place this information in a different file. Sorry for my ignorance.

    Secondly, I can't find a way to specify template page in the Write Page area. The only options in the right sidebar are: Discussion, Password-Protect, Parent, Post Slug, Post Author and Post Order. There doesn't seem to be a link here for selecting page order.

    I'm pretty new to php, MySQL and customizing themes in WordPress, so I really appreciate the help.

    @maerk - Your suggestion didn't seem to work, maybe I'm misinterpretting what that function does. Does that function create a link to a page listing the archives in a sequence of titles or does it create the sequence of titles. I'm pretty sure I can do the latter, it is the problem of accessing that php script for my page that is difficult.

    Thanks,
    -Scott

  5. Ryan Fitzer
    Member
    Posted 8 years ago #

    Secondly, I can't find a way to specify template page in the Write Page area. The only options in the right sidebar are: Discussion, Password-Protect, Parent, Post Slug, Post Author and Post Order. There doesn't seem to be a link here for selecting page order.

    You have to go to Write > Page and not Write > Post. You can not put archives in a post. Pages and posts are very different.

    This might help a little more:

    http://codex.wordpress.org/Pages#Page_Templates

  6. ScottHYoung
    Member
    Posted 8 years ago #

    Alright I set up the page template. It wasn't showing because the theme I was using didn't have any page templates.

    My problem now is that my previous method for getting all the posts and their titles won't work. Are there any functions you can call to loop through and get every post (not page) ever made instead of just the ones indicated by the page type? Currently I'm using:

    <?php if (have_posts()); while (have_posts()); (the_post()); ?>

    //Display and format each title here

    <?php endif; endwhile; ?>

    But the function have_posts() seems to only call the posts necessary for that page, not every post. Any ideas?

    There wouldn't happen to be an area of this site that lists all of these predefined php functions would there?

  7. ScottHYoung
    Member
    Posted 8 years ago #

    Okay I found out how to do it. Thanks for the help guys!

  8. Ryan Fitzer
    Member
    Posted 8 years ago #

    Glad to hear you got it. Could you post your particular solution for other benifit as well as mark the post as resolved (drop-down up top).

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags