WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Function to distinguish pages and posts (7 posts)

  1. fabian.schmid
    Member
    Posted 6 years ago #

    I've put the the_meta-tag (custom fields) in my index-file of the WordPress installation. But I do not want to display the custom fields on static pages, but only on posts of my blog. I'm searching a function that distinguishes between a page (like impressum e.g.) and a post (like this is my first post, welcome to my blog e.g.). Can someone help me?
    Thanks in advance...

  2. Kalessin
    Member
    Posted 6 years ago #

  3. fabian.schmid
    Member
    Posted 6 years ago #

    I thougt it was this function firstly, but I tried it and it didn't work

    <?php if(!is_page()){
         the_meta();
    } ?>

    Can you help me?

  4. Kalessin
    Member
    Posted 6 years ago #

    That should work. What happens? Do you definitely have something in the custom fields for the post? Test it with:
    <?php if ( !is_page() ) { echo '<p>Not a Page!</p>'; } ?>

  5. fabian.schmid
    Member
    Posted 6 years ago #

    The custom fields are displayed on every post and on every page too, but since they're empty in the page-pages, there are only the bullets (because it's structured with ul and li...
    And thanks for the hint I'm gonna test it when I'm at home...

  6. fabian.schmid
    Member
    Posted 6 years ago #

    Oh how dumd I am! I've put the_meta(); in sinlge.php and page.php with the built in theme editor and in index.php.
    I'm sorry for your effort...

  7. Kalessin
    Member
    Posted 6 years ago #

    Can you mark this post as resolved then, please?

Topic Closed

This topic has been closed to new replies.

About this Topic