Support » Themes and Templates » Function to distinguish pages and posts

  • Resolved fabian.schmid

    (@fabianschmid)


    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…

Viewing 6 replies - 1 through 6 (of 6 total)
  • Kalessin

    (@kalessin)

    fabian.schmid

    (@fabianschmid)

    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?

    Kalessin

    (@kalessin)

    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>'; } ?>

    fabian.schmid

    (@fabianschmid)

    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…

    fabian.schmid

    (@fabianschmid)

    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…

    Kalessin

    (@kalessin)

    Can you mark this post as resolved then, please?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Function to distinguish pages and posts’ is closed to new replies.