0

This is the code for an archive page on my website, when I try to open this page, it brings up a 404 error and doesn't display any content. Is there a problem in this code that is stopping it? I am using the Custom Post Types plugin for the archive content.

<?php get_header(); ?>



<style type="text/css">
.b33 { float:left; width: 33%; padding-left: 25px; padding-top: 35px; }
.b33 img  { max-width:100%; border:8px solid #91B49C;float:left; height:200px; overflow:hidden;}

</style>

<?php // IMAGE SLIDESHOW ?>
<div id="content" style="border-bottom: 1px solid #664422; background-color:#F0FFF0; border-top: 1px solid #664422; margin-top:0; height:670px;">
<div id="inner-content" class="wrap cf">
<div class="fadein" style="width:100%; overflow:hidden; height:670px;">

  <img style="width:100%;border:8px solid #91B49C; margin:1em 0 1em 0;" src="<?php echo get_site_url(); ?>/wp-content/uploads/2016/05/Wedding-1.jpg">
  <img style="width:100%;border:8px solid #91B49C; margin:1em 0 1em 0;" src="<?php echo get_site_url(); ?>/wp-content/uploads/2016/05/Wedding-2.jpg">
  <img style="width:100%;border:8px solid #91B49C; margin:1em 0 1em 0;" src="<?php echo get_site_url(); ?>/wp-content/uploads/2016/05/Funeral-5.jpg">

</div>
</div>
</div>
<?php // END OF IMAGE SLIDESHOW ?>

   <div id="content" style="background-color:#E0EEE0; margin-top:0; border-bottom:1px solid #664422;">
<div id="inner-content" class="wrap cf">
    <h1 class="page-title-text" style="text-align:center; font-family: 'Josefin Slab', serif; color:#664422;" >Birthday & Anniversary</h3>
</div>
</div>


    <div id="primary" class="content-area" style="background-color:#F0FFF0; border-bottom:1px solid #664422;>  
        <div id="content" class="site-content" role="main">
    <div id="inner-content" class="wrap cf">
            <?php $loop = new WP_Query( array( 'post_type' => 'birthdays', 'order' => 'ASC', 'posts_per_page' => -1 ) ); ?>
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
        <div class="b33" style=" margin:0.5em 0.5em 0.5em 0.5em; border: 8px solid #91B49C; height:350px; width:31.5%; float:left; background-size: cover; background-repeat: no-repeat; overflow:hidden;  background-image: url('<?php the_field( 'image' ); ?>')">




            </div>

    <?php endwhile; wp_reset_query(); ?>

    </div>
        </div><!-- #content -->
    </div><!-- #primary -->



<?php get_footer(); ?>
1
  • What URL are you calling that returns a 404? No need to reveal the domain, just the part after the first / is fine. Which template file is this code in? May 19, 2016 at 13:06

1 Answer 1

2

You should mention register function in your Question. Add flush_rewrite_rules( false ); in Your custom_post_type register function. it is necessary when you are creating custom post with archive.

example code:

function create_my_post_type(){
     register_post_type('MyPost', array(
                       'labels' => array('name' =>__('My-custom-Post'),'singular_name' => __('my-post')),
                         'rewrite' => array('slug' => 'MyPost','with_front' => true),
                          'public'=>true,
                          'has_archive' => true,
                       ));
      flush_rewrite_rules(false);    //recreate rewrite rules.
}

add_action('init','create_my_post_type');
1

Not the answer you're looking for? Browse other questions tagged or ask your own question.