Custom fields on custom post type archive

I’ve run into the following problem.

I’ve made 2 custom post types, each, ofcourse, containing posts.

Read More

But now I’ve run into a situation where I would need to add a custom field at the top of the archive page.

Since I don’t have a page I can access on the admin side, I can’t fill these custom fields.

Should I switch to a page, or is there a other way?

I hope this is clear enough.

Related posts

Leave a Reply

1 comment

  1. May way of doing this is to create a page and put the content in there then use the following code at the top of your archive”post-type”.php to display it.

    $myposts = get_posts( array('post_type'=>'page','numberposts' => 1,'include' => 45) );
    foreach( $myposts as $post ) :  setup_postdata($post); ?>
    
        <article id="post-<?php the_ID(); ?>" <?php post_class('grid_5'); ?>>
                    <header class="entry-header">
                        <h1 class="entry-title"><?php the_title(); ?></h1>
                    </header><!-- .entry-header -->
                    <div class="entry-content">
                        <?php the_content(); ?>
                    </div><!-- .entry-content -->
                </article><!-- #post-<?php the_ID(); ?> -->
             <?php endforeach; // end of the loop. ?>
    

    All you need to do is replace the ‘include’ => 45 with your own page id.