Support » Fixing WordPress » Showing news archive on page?

  • I’ve been trying to set a page called “archives.php” on my site to display all older news, however, I run into errors.

    I copy the code from archives.php on the default theme and paste it into my editor – name it “archives.php” and when I go to preview it I get this error:

    Fatal error: Unknown function: get_header() in /home/minnie/domains/ on line 1

    I tried changing the get_header to header.php (as well as my footer) so it’s like this:


    But that leaves me with this:

    Parse error: syntax error, unexpected ‘<‘ in /home/minnie/domains/ on line 4

    I can’t seem to get it working. I wanted to get my archives like this or this here : .

    Anyone know what I’m doing wrong, how can I fix this?

    Thanks 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The code in archives.php needs to be run in a WordPress context. What that means is

    1. Create the archives.php, modeled on the archives.php from the default theme and a file like index.php or page.php from your current theme. Save it in (or upload it to) the directory with the rest of the files from your theme. [Don’t put it in the top level in public_html.]

    2. At the top of archives.php, you’ll see code like

    Template Name: Archives

    This snippet is important. The template name will be used in the next step.

    3. Login to WordPress and go to the Administration > Write > Page panel and create a new page. Enter a Page Title of Archives and, in the Page Template dropdown on the right, select the template Archives. [If you create other templates, you’d give them different names and use this drop-down to tie them to a page.] Add other text that you want but which isn’t included in the archives.php — or just leave the page body blank. Publish the page.

    4. Browse to (not archives.php) and you might not get exactly what you want, but you should get past the “Fatal error” above.

    This Codex page on the Template Hierarchy is useful in figuring out what code will be used to display a particular page.

    Thanks so much!! 😀

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Showing news archive on page?’ is closed to new replies.