Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * Display the Tip of the Day Custom Post Type archive custom fields using
- * ACF.
- *
- * @author Angie Meeker
- * @uses Advanced Custom Fields
- */
- add_action('genesis_entry_content','genesis_do_post_title', 2);
- //* Add Tip of the Day body class to the head
- add_filter( 'body_class', 'add_tiparchives_body_class' );
- function add_tiparchives_body_class( $classes ) {
- $classes[] = 'tiparchives-post-type-archive-{tipoftheday}';
- return $classes;
- }
- // Return Category and Tip of the Day on Single Posts
- add_action ( 'genesis_before_content', 'show_totd', 9 );
- function show_totd() {
- echo '<div class="totd-cats-title">Tip of the Day</div>';
- }
- // Remove Post Author
- add_filter( 'genesis_post_info', 'remove_post_author_totd_posts' );
- function remove_post_author_totd_posts($post_info) {
- $post_info = '[post_date]';
- return $post_info;
- }
- /** Replace the standard loop with our custom loop */
- remove_action( 'genesis_loop', 'genesis_do_loop' );
- add_action( 'genesis_loop', 'totd_do_loop');
- add_action( 'genesis_loop', 'totd_teasers_do_loop');
- add_action('genesis_loop', 'totd_do_loop');
- function totd_do_loop() {
- if ( !is_paged() ) {
- global $wp_query;
- // Set up your query here
- $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
- $query = array(
- 'post_type' => 'tipoftheday',
- 'orderby' => 'date',
- 'posts_per_page' => '1',
- );
- $wp_query = new WP_Query( $query );
- if( $wp_query->have_posts() ):
- while( $wp_query->have_posts() ): $wp_query->the_post();
- // Get the custom fields
- // Store the pre tips data
- $tips_data_pre = array(
- 'totd_tags' => get_field( 'totd_tags' ),
- 'tip_article_headline' => get_field( 'tip_article_headline' ),
- 'article_author' => get_field( 'article_author' ),
- 'article_author_link' => get_field( 'article_author_link' ),
- );
- // Only output if we have tips data
- if ($tips_data_pre['totd_tags'] != '' ||
- $tips_data_pre['tip_article_headline'] != '' ||
- $tips_data_pre['article_author'] != '' ||
- $tips_data_pre['article_author_link'] != '') {
- echo '<span class="date time published" title="%1$s">' , do_shortcode('[post_date]'),'</span>' ;
- echo '<div class="tip-excerpt"><p><div class="entry-content">';
- echo '<div class=h1 entry-title"><a href="'.get_permalink().'"title="'.get_the_title().'">' . get_the_title() . '</a></div>';
- echo the_excerpt();
- echo '<div class="entry-terms">' , do_shortcode('[post_terms taxonomy="totd_tags" before="See More Tips For: " taxonomy="totd_tags"] '),'</div>' ;
- echo '<div class="entry-terms">
- <div class="share">Share This Tip:</div>
- <div class="addthis_toolbox addthis_default_style">
- <a class="addthis_button_preferred_1"></a>
- <a class="addthis_button_preferred_2"></a>
- <a class="addthis_button_preferred_3"></a>
- <a class="addthis_button_preferred_4"></a>
- <a class="addthis_button_compact"></a>
- <a class="addthis_counter addthis_bubble_style"></a>
- </div>
- <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=manta"></script>
- </div>
- </div></div>';
- echo '</p>';
- }
- endwhile;
- endif;
- // Reset the query
- wp_reset_query();
- }
- }
- add_action('genesis_loop', 'totd_teasers_do_loop');
- function totd_teasers_do_loop() {
- global $wp_query;
- // Set up your query here
- $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 0;
- $query = array(
- 'post_type' => 'tipoftheday',
- 'orderby' => 'date',
- 'posts_per_page' => '10',
- 'offset' => '1',
- 'paged' => $paged,
- );
- $wp_query = new WP_Query( $query );
- if( $wp_query->have_posts() ):
- while( $wp_query->have_posts() ): $wp_query->the_post();
- // Get the custom fields
- // Store the pre tips data
- $tips_data_pre = array(
- 'totd_tags' => get_field( 'totd_tags' ),
- 'tip_article_headline' => get_field( 'tip_article_headline' ),
- 'article_author' => get_field( 'article_author' ),
- 'article_author_link' => get_field( 'article_author_link' ),
- );
- // Only output if we have tips data
- if ($tips_data_pre['totd_tags'] != '' ||
- $tips_data_pre['tip_article_headline'] != '' ||
- $tips_data_pre['article_author'] != '' ||
- $tips_data_pre['article_author_link'] != '') {
- echo '<div class="time-teaser">
- <span class="day">',get_the_time( 'l' ),'</span>
- <span class="month">',get_the_time( 'm/d/Y' ),'</span> </div>';
- echo '<div class="tip-excerpt"><p><div class="entry-content">';
- echo '<div class=h2 entry-title"><a href="'.get_permalink().'"title="'.get_the_title().'">' . get_the_title() . '</a></div>';
- $excerpt = get_the_excerpt();
- echo string_limit_words($excerpt,25); echo '<a class="moretag" href="'. get_permalink($post->ID) . '"> Continue Reading→</a>';
- echo '<div class="entry-terms">' , do_shortcode('[post_terms taxonomy="totd_tags" before="See More Tips For: " taxonomy="totd_tags"] '),'</div>' ;
- echo '<div class="entry-terms"></div>
- </div></div>';
- echo '</p>';
- }
- endwhile;
- // Pagination! Woo!
- genesis_posts_nav();
- endif;
- // Reset the query
- wp_reset_query();
- }
- genesis();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement