Forums

A Page of Posts Isn't Working (7 posts)

  1. Godaisies
    Member
    Posted 1 year ago #

    I tried using the Codex on Pages to get A Page of Posts working. I made a pageofposts.php with the code the Codex gives, went to my page and choose the pageofposts template, then made a custom field called "category" with the input text of name of the category I want called in.

    When I went to view the page, all I got was the text from the pageofposts.php. WTF.

    What am I doing wrong?

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    without either seeing your site or your code, difficult to say.

    could you paste the code of that template page into a http://wordpress.pastebin.com/ and post the link to it here?

  3. Godaisies
    Member
    Posted 1 year ago #

    http://wordpress.pastebin.com/9wtRdbr0

    All I did was copy pasta it from the Codex page with zero changes.

    I'm calling my posts in by category like so: http://lisuncg.net/news-and-events/category/headline/ but I'd rather just have http://lis.uncg.edu/news-and-events/headlines/ so it looks more like a regular list of posts rather than like the archives.

  4. Digital Raindrops
    Member
    Posted 1 year ago #

    Looking at the code

    $category = get_post_meta($posts[0]->ID, 'category', true);

    If I am reding this right, you should have a custom field on the page called 'category' with the value 'headlines', then apply the new template, is this what you have?

    HTH

    David

  5. alchymyth
    The Sweeper
    Posted 1 year ago #

    check that the pageofposts template file has the extension .php and that there is nothing before the <?php at the beginnning.
    (in your link, the browser finds at the beginning, which should not be there):

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <pre>

    more important:
    the example in the codex has a html structure for the old default theme kubrick; it will definitely not match your other pages, and even when you get it working, it will look very different.

  6. Godaisies
    Member
    Posted 1 year ago #

    @Adeptris: Yep, that's what I got (except my category is "Headline").

    @alchymyth: I just downloaded pageofposts.php and yes, the extension is .php and there is nothing above the initial <php.

  7. Digital Raindrops
    Member
    Posted 1 year ago #

    Godaisies,
    The example code is for reference only as alchymyth pointed out, you need to create a template page specific to your theme structure. this would need to be a template page modified index.php, or mix of page.php and index.php if you want a page text section as well.

    can you find the file page.php and index.php and copy the contents of these to pastebin, then you may get some help that matches your theme.

    I have something like this for the twenty ten theme, and you can see it is different for each theme.

    This one might be better for you, as all you do is have a page and category slug that match, code

    I use it on my website page here, where the page and category slugs are both 'templates', and has both page text and posts.

    If you pastebin the two files so we can have a look, will be a good start.

    David

Topic Closed

This topic has been closed to new replies.

About this Topic