Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End [SOLVED] Troubleshooting get_posts() on my Static Home Page

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #26646
    TXChetG
    Member

    I have a site set up to function only on WordPress, but I am having a problem I have never come across before. I have my home page set to be a static page, while my posts are displayed as a portfolio. I also wanted to have the ability to display my posts that are not Portfolio Entries on the home page as an updates section.

    After doing some reading through the Codex I decided that get_posts(); would be the most efficient way to do this. After developing and running my PHP and HTML I have run across my issue. Seen here: http://chetgproductions.com.

    After the posts are displayed the template tags seem to become confused. Where I use the_title(); it displays the title of the page, not the title of that post, the same thing happens with the date.

    Here is the coding I am using:

    Code:

    The coding is derived directly from the WP Codex, and it works exactly as it should, except these minor details. If any of you have some insight on how to address this problem please pass along your knowledge. It’s greatly appreciated.

    *UPDATE*

    I’ve done some more reading into the Codex, and have employed this code:

    Code:

    post_title; ?>

    Posted on post_date; ?>

    Querying the table columns proved successful, however this is not how I would like to do this. For some reason the setup_postdata(); command just isn’t letting me access the post’s meta data as I would like to. I can live with this temporary fix for now, but would really appreciate the advice of anyone out there on this.

    #66203
    TXChetG
    Member

    I am also toying with this as a way to do what I want:

    Code:

    However it is causing two instances of the posts to be displayed. Why would it cause this?

    See it here: http://chetgassett.com/sand-box

    *UPDATED*

    Code:

    I am trying this now, but after instituting wp_reset_query(); the page title is just looping over, and over, and over again on the "sand-box" page above. I experience this same problem when trying to just run a loop on a page. What do you all think?

    #66205
    TXChetG
    Member

    Changed my code to this:

    Code:

    Everything works like a charm now.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.