mirror of
https://github.com/10h30/yeuchaybo-v6.git
synced 2026-06-05 15:10:05 +09:00
Modify post meta info on event archive page: add date and location
This commit is contained in:
+2
-39
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Template Name: Testimonial Archives
|
* Template Name: Events Archive
|
||||||
* Description: Used as a page template to show page contents, followed by a loop through a CPT archive
|
* Description: Used as a page template to show page contents, followed by a loop through a CPT archive
|
||||||
*/
|
*/
|
||||||
remove_action ('genesis_loop', 'genesis_do_loop'); // Remove the standard loop
|
remove_action ('genesis_loop', 'genesis_do_loop'); // Remove the standard loop
|
||||||
@@ -17,6 +17,7 @@ function child_do_custom_loop() {
|
|||||||
'orderby' => 'meta_value', // sort by the event_date
|
'orderby' => 'meta_value', // sort by the event_date
|
||||||
'order' => 'asc',
|
'order' => 'asc',
|
||||||
'posts_per_page'=> '12',
|
'posts_per_page'=> '12',
|
||||||
|
'post_status' => 'publish',
|
||||||
'paged' => $paged,
|
'paged' => $paged,
|
||||||
'meta_query' => array( // WordPress has all the results, now, return only the events after today's date
|
'meta_query' => array( // WordPress has all the results, now, return only the events after today's date
|
||||||
array(
|
array(
|
||||||
@@ -32,44 +33,6 @@ function child_do_custom_loop() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//add_action( 'genesis_loop', 'custom_do_grid_loop' ); // Add custom loop
|
|
||||||
function custom_do_grid_loop() {
|
|
||||||
|
|
||||||
$args = array(
|
|
||||||
'post_type' => 'event', // enter your custom post type
|
|
||||||
'meta_key' => '_event_start_date', // load up the event_date meta
|
|
||||||
'orderby' => 'meta_value', // sort by the event_date
|
|
||||||
'order' => 'asc',
|
|
||||||
'posts_per_page'=> '6', // overrides posts per page in theme settings
|
|
||||||
'meta_query' => array( // WordPress has all the results, now, return only the events after today's date
|
|
||||||
array(
|
|
||||||
'key' => '_event-start-date', // Check the start date field
|
|
||||||
'value' => date("Y-m-d"), // Set today's date (note the similar format)
|
|
||||||
'compare' => '>=', // Return the ones greater than today's date
|
|
||||||
'type' => 'DATE' // Let WordPress know we're working with date
|
|
||||||
)
|
|
||||||
),
|
|
||||||
);
|
|
||||||
$loop = new WP_Query( $args );
|
|
||||||
if( $loop->have_posts() ):
|
|
||||||
|
|
||||||
while( $loop->have_posts() ): $loop->the_post(); global $post;
|
|
||||||
echo '<div id="testimonials">';
|
|
||||||
echo '<div class="one-fourth first">';
|
|
||||||
echo '<div class="quote-obtuse"><div class="pic">'. get_the_post_thumbnail( $id, array(150,150) ).'</div></div>';
|
|
||||||
echo '</div>';
|
|
||||||
echo '<div class="three-fourths" style="border-bottom:1px solid #DDD;">';
|
|
||||||
echo '<h3>' . get_the_title() . '</h3>';
|
|
||||||
echo '</div>';
|
|
||||||
echo '</div>';
|
|
||||||
|
|
||||||
endwhile;
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Remove Post Info */
|
/** Remove Post Info */
|
||||||
remove_action('genesis_before_post_content','genesis_post_info');
|
remove_action('genesis_before_post_content','genesis_post_info');
|
||||||
remove_action('genesis_after_post_content','genesis_post_meta');
|
remove_action('genesis_after_post_content','genesis_post_meta');
|
||||||
|
|||||||
+4
-2
@@ -37,6 +37,10 @@ load_child_theme_textdomain( CHILD_TEXT_DOMAIN, apply_filters( 'child_theme_text
|
|||||||
// Enable support for page excerpts.
|
// Enable support for page excerpts.
|
||||||
add_post_type_support( 'page', 'excerpt' );
|
add_post_type_support( 'page', 'excerpt' );
|
||||||
|
|
||||||
|
//Add post type archive support for event
|
||||||
|
add_post_type_support( 'event', 'genesis-cpt-archives-settings' );
|
||||||
|
|
||||||
|
|
||||||
// Enable support for Gutenberg wide images.
|
// Enable support for Gutenberg wide images.
|
||||||
add_theme_support( 'align-wide' );
|
add_theme_support( 'align-wide' );
|
||||||
|
|
||||||
@@ -375,5 +379,3 @@ function abte_add_site_description_class( $attributes ) {
|
|||||||
return $attributes;
|
return $attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add post type archive support
|
|
||||||
add_post_type_support( 'event', 'genesis-cpt-archives-settings' );
|
|
||||||
|
|||||||
@@ -457,6 +457,14 @@ function corporate_post_info_date( $post_info ) {
|
|||||||
$post_info = '[post_date]';
|
$post_info = '[post_date]';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
global $post;
|
||||||
|
$EM_Event = em_get_event($post->ID, 'post_id');
|
||||||
|
$location = $EM_Event->output('#_LOCATIONTOWN');
|
||||||
|
|
||||||
|
if (is_post_type_archive('event')) {
|
||||||
|
$post_info = '[field _event_start_date date_format="d/m/Y"]';
|
||||||
|
$post_info .= ' - '.$location;
|
||||||
|
}
|
||||||
|
|
||||||
return $post_info;
|
return $post_info;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user