Forums

Making wp realise it's a page, not a post (4 posts)

  1. intothewhite
    Member
    Posted 1 year ago #

    Hi - I have created a page template entitled Clients Page. The template has a loop which displays all post titles and their excerpts, using query_posts.

    I created a page called Clients using the Clients Page template.

    In my sidebar.php file I use conditional tags to display different things according to the page I'm on. I want something specific displayed when the page is Clients, so I use:

    elseif (is_page('Clients')) {

    The problem I have is that wp doesn't think the page is Clients. Because I've used query_posts, it thinks the page is the oldest post in the database. Consequently, the correct code isn't shown.

    I guess I could use is_single('title of the oldest post') instead of (is_page('Clients')), but it'd be a lot better to get wp to recognise the page as Clients.

    Any ideas how I could do this?

  2. Darran
    Member
    Posted 1 year ago #

    If it is a single page, why should you be doing a query_post()?

  3. intothewhite
    Member
    Posted 1 year ago #

    Because I want the page to query the database - I write posts that detail work that has been done with clients (and these posts are tagged 'client'). The page pulls all posts tagged 'client' from the database, and displays a link, the title and the excerpt.

    Thanks,

    Leon

  4. moshu
    Member
    Posted 1 year ago #

    The page pulls all posts tagged 'client' from the database (emphasis mine)

    Which means it doesn't behave anymore as a Page pulling the content from a single entry... so WP, correctly, perceives it as something else, not a Page. That's my guess.

    If those post are really "tagged" as 'client' - (meaning they have a tag like that), you could just use a tag-specific template to display them:
    Template_Hierarchy#Tag_display

Topic Closed

This topic has been closed to new replies.

About this Topic