Skip to content

Commit

Permalink
single e archive agenda
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusgimenez committed Apr 24, 2019
1 parent afe9716 commit c0f5f70
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 20 deletions.
59 changes: 59 additions & 0 deletions archive-el_events.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
*
* @link https://developer.wordpress.org/themes/template-files-section/page-template-files/
*
* @package coletivo
*/

get_header(); ?>
<div id="content" class="container">
<?php $current_date = date('Y-m-d');?>
<?php $query = new WP_Query(
array(
'post_type' => 'el_events',
'posts_per_page' => -1,
'orderby' => 'meta_value',
'meta_key' => 'startdate',
'meta_compare' => '>=',
'meta_value' => $current_date,
'order' => 'ASC'
)
);
?>
<?php if ( $query->have_posts() ) : ?>
<h1 class="the-title">
<?php _e( 'Agenda - Proximos eventos', 'csem-theme' );?>
</h1><!-- .the-title -->
<div class="col-md-12 agenda-container">
<?php while( $query->have_posts() ) : $query->the_post(); ?>
<?php get_template_part( 'section-parts/each-agenda' ); ?>
<?php endwhile;?>
</div><!-- .col-md-12 agenda-container -->
<?php endif;?>
<?php $query = new WP_Query(
array(
'post_type' => 'el_events',
'posts_per_page' => -1,
'orderby' => 'meta_value',
'meta_key' => 'startdate',
'meta_compare' => '<',
'meta_value' => $current_date,
'order' => 'ASC'
)
);
?>
<?php if ( $query->have_posts() ) : ?>
<h1 class="the-title">
<?php _e( 'Agenda - Eventos Anteriores', 'csem-theme' );?>
</h1><!-- .the-title -->
<div class="col-md-12 agenda-container">
<?php while( $query->have_posts() ) : $query->the_post(); ?>
<?php get_template_part( 'section-parts/each-agenda' ); ?>
<?php endwhile;?>
</div><!-- .col-md-12 agenda-container -->
<?php endif;?>

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

<?php get_footer();
22 changes: 22 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,25 @@ function csem_agenda() {

// Classe para seção ultimos posts das redes
require_once get_stylesheet_directory() . '/inc/class-load-last-post-social-networks.php';

/**
* Função para exibir todos posts no archive da agenda
*/
function hwl_home_pagesize( $query ) {
if ( is_admin() || ! $query->is_main_query() || ! is_post_type_archive( 'el_events' ) ) {
return;
}
$query->set( 'posts_per_page', 9999999 );
if ( is_home() ) {
// Display only 1 post for the original blog archive
$query->set( 'posts_per_page', 1 );
return;
}

if ( is_post_type_archive( 'movie' ) ) {
// Display 50 posts for a custom post type called 'movie'
$query->set( 'posts_per_page', 50 );
return;
}
}
add_action( 'pre_get_posts', 'hwl_home_pagesize', 1 );
21 changes: 21 additions & 0 deletions section-parts/each-agenda.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div class="col-md-4 each-agenda">
<?php $thumb_url = get_the_post_thumbnail_url( get_the_ID(), 'large' );?>
<div class="the-thumb" style="background-image:url('<?php echo esc_url( $thumb_url );?>">
<a href="<?php the_permalink();?>">
<h3 class="the-title">
<?php if ( ! is_singular( 'el_events' ) ) : ?>
<?php the_title();?>
<?php endif;?>
</h3><!-- .the-title -->
<?php if ( $meta = get_post_meta( get_the_ID(), 'startdate', true ) ) : ?>
<?php $date = new DateTime( $meta );?>
<h4 class="the-date"><?php echo $date->format( 'd/m');?></h4><!-- .the-date -->
<?php endif;?>
</a>
</div><!-- .the-thumb -->
<h4 class="the-time">
<?php if ( $meta = get_post_meta( get_the_ID(), 'starttime', true ) ) : ?>
<?php printf( __( 'A partir das %shrs', 'csem-theme' ), $meta );?>
<?php endif;?>
</h4><!-- .the-time -->
</div><!-- .col-md-4 each-agenda -->
22 changes: 2 additions & 20 deletions section-parts/shortcode-agenda.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,14 @@
'post_type' => 'el_events',
'posts_per_page' => 3,
'orderby' => 'meta_value',
'meta_value_num' => 'startdate',
'meta_key' => 'startdate',
'order' => 'ASC'
)
);
?>
<?php if ( $query->have_posts() ) : ?>
<?php while( $query->have_posts() ) : $query->the_post(); ?>
<div class="col-md-4 each-agenda">
<?php $thumb_url = get_the_post_thumbnail_url( get_the_ID(), 'large' );?>
<div class="the-thumb" style="background-image:url('<?php echo esc_url( $thumb_url );?>">
<a href="<?php the_permalink();?>">
<h3 class="the-title">
<?php the_title();?>
</h3><!-- .the-title -->
<?php if ( $meta = get_post_meta( get_the_ID(), 'startdate', true ) ) : ?>
<?php $date = new DateTime( $meta );?>
<h4 class="the-date"><?php echo $date->format( 'd/m');?></h4><!-- .the-date -->
<?php endif;?>
</a>
</div><!-- .the-thumb -->
<h4 class="the-time">
<?php if ( $meta = get_post_meta( get_the_ID(), 'starttime', true ) ) : ?>
<?php printf( __( 'A partir das %shrs', 'csem-theme' ), $meta );?>
<?php endif;?>
</h4><!-- .the-time -->
</div><!-- .col-md-4 each-agenda -->
<?php get_template_part( 'section-parts/each-agenda' ); ?>
<?php endwhile;?>
<?php endif;?>
</div><!-- .col-md-12 agenda-container -->
Expand Down
28 changes: 28 additions & 0 deletions single-el_events.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
*
* @link https://developer.wordpress.org/themes/template-files-section/page-template-files/
*
* @package coletivo
*/

get_header(); ?>
<?php while( have_posts() ) : the_post(); ?>
<div id="content" class="container">
<h1 class="the-title">
<?php the_title();?>
</h1><!-- .the-title -->
<div class="col-md-12 agenda-container">
<?php get_template_part( 'section-parts/each-agenda' ); ?>
</div><!-- .col-md-12 agenda-container -->
</div><!-- #content -->
</div><!-- #page -->
<div class="hfeed site">
<div class="container" id="the-content">
<h3>
<?php _e( 'SOBRE O EVENTO: ', 'csem-theme' );?>
</h3>
<?php the_content();?>
</div><!-- #the-content.container -->
<?php endwhile;?>
<?php get_footer();
26 changes: 26 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,29 @@ a#featuredpage {
background-repeat: no-repeat;
padding-top: 100px;
}

/* Archive el_events */
body.post-type-archive-el_events #page {
background:#f1ca61;
}
body.post-type-archive-el_events h1.the-title, body.single-el_events h1.the-title {
text-align: center;
color: #333333;
text-transform: uppercase;
font-weight: 800;
padding-bottom: 20px;
}
body.post-type-archive-el_events .agenda-container {
padding-bottom: 120px;
display: block;
}
/* Single el_events */
body.single-el_events #page {
background:#f1ca61;
clear:both;
border-bottom: 0.8px solid rgba(0,0,0,0.10 );
margin-bottom: 40px;
}
body.single-el_events #the-content {
padding-bottom: 40px;
}

0 comments on commit c0f5f70

Please sign in to comment.