• I’m tying to use WP as a CMS system as well as a blog for a “Projects” section. I have a static front page, and it is set up like this:

    Front page displays: A static page
    Front page: Home
    Posts page: Latest Projects

    Home is using a file called “template_home.php”, and the posts page for Latest Projects is using “index.php”

    When editing a page, I have a custom field used for a description of the page. Too pull this data in, I use this code on both pages, in exactly the same place:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php the_meta(); ?>
    <?php endwhile; endif; ?>

    This works perfectly for “template_home.php”, but for “index.php” the custom field content will not show up.

    To clarify, “template_home.php” and “index.php” have the code above in exactly the same place, and there are only minor differences between “index.php” and “template_home.php”.

    Is there something I am missing to why it wont work on the page with the blog posts?

    Thanks.

Viewing 1 replies (of 1 total)
  • I think I have the exact same problem.
    Im using custom fields to add a picture to each page like so:
    <img class="header_img" src="<?php echo get_post_meta($post->ID, "header_image", true); ?>">

    Which is cool on normal pages (home is static) but on my news page(index.php) it seems the custom field info is pulled from the posts

    I have created a news page, how can I pull from the custom field of this page not the posts on the actual index page?

Viewing 1 replies (of 1 total)
  • The topic ‘Custom fields on index.php’ is closed to new replies.