Skip to content

Instantly share code, notes, and snippets.

@dividezigns
Last active April 17, 2023 03:10
Show Gist options
  • Save dividezigns/9192079b5e14379ffabc6bad84390afb to your computer and use it in GitHub Desktop.
Save dividezigns/9192079b5e14379ffabc6bad84390afb to your computer and use it in GitHub Desktop.
This template can be used as an archive page for a custom post type in Divi. Create a file and name it archive-your_custom_post_name.php. and place it in your child theme's directory.
<?php
/* =====
Template Name: Custom Post Type Archive
===== */
get_header();
$custom_post_type_function = new WP_Query(
array(
'post_type' => 'custom_post_type',
'post_status' => 'publish',
'posts_per_page' => 8,
'order' => 'DESC',
'paged' => $paged
));
$classIncrement = 0;
?>
<div id="main-content">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-content">
<div class="et_pb_section et_section_regular">
<div class="et_pb_row et_pb_gutters2 et_pb_row_fullwidth et_pb_row_4col">
<?php
if($custom_post_type_function ->have_posts()) {
$i = 0;
while($custom_post_type_function ->have_posts()): $custom_post_type_function ->the_post();?>
<div class="et_pb_column et_pb_column_<?php echo $classIncrement++ ?> et_pb_column_1_4">
<div class="et_pb_text et_pb_module et_pb_bg_layout_light et_pb_text_align_left">
<div class="et_pb_text_inner">
<h2><?php the_title();?></h2>
<p>Custom Post Type Data.</p>
</div>
</div> <!-- .et_pb_text -->
</div> <!-- .et_pb_column -->
<?php
$i++;
if($i % 4 == 0) echo '</div><div class="et_pb_row et_pb_gutters2 et_pb_row_fullwidth et_pb_row_4col" >';
endwhile;
}
?>
</div> <!-- row -->
</div> <!-- section -->
</div> <!-- .entry-content -->
</article> <!-- .et_pb_post -->
</div>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment