• Resolved vamped

    (@vamped)


    Hey there folks,

    I’m wondering if it is possible (and how) to put posts on a non-template page. For example, if you check out this site:

    http://www.after8tcdsb.com

    Click on the “Answer a Question” button to the right. Essentially a dialog box appears and in that I would like to include 5 questions from the site. When I try doing the normal string to show posts, I get an error.

    Any suggestions?

    Thanks, James

Viewing 6 replies - 1 through 6 (of 6 total)
  • When I try doing the normal string to show posts, I get an error.

    What “normal string” and what “error”?

    <?php
    //a simple loop to display 5 post:
    $posts=get_posts('post_type=post&showposts=5');
    if ($posts) {
      foreach($posts as $post) {
        setup_postdata($post);
        ?>
        <p><?php the_time('m.d.y') ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
      <?php }
    }
    ?>
    Thread Starter vamped

    (@vamped)

    Hey Michael thanks for the response. If you look at the site now it shows the error. Essentially, I copied the same code I have in my header.php file and included what you’ve given me as well in the body of the document, and I get an error… It doesn’t know what to do with the PHP functions I’ve put there. Is there something I’m supposed to include for the page to look for the functions in? If I use the same code on a template page (e.g. index.php) everything works fine.

    Thanks!

    If you want to put code in an actual post or page, then look at a plugin such as http://wordpress.org/extend/plugins/exec-php/

    Thread Starter vamped

    (@vamped)

    It’s not a post or page that I’m writing it in though… Will this still help?

    The dialog box is a file named “answer.php” which isn’t recognized by WordPress at all. I just need to figure out how to make whatever strings and PHP I use in there (all that relate to WordPress) actually function and not wonder where I came up with these functions.

    Thanks for the help, Michael!

    Hmm, wonder if this will help you:

    Integrating_WordPress_with_Your_Website

    And you are welcome.

    Thread Starter vamped

    (@vamped)

    That’s exactly what I’m looking for! Thanks so much Mike!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Showing Posts on a Non-Template Page’ is closed to new replies.