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);
- //* Removes Continue Reading from the echoed excerpt
- function sbt_auto_excerpt_more( $more ) {
- return 'aaa';
- }
- add_filter( 'excerpt_more', 'sbt_auto_excerpt_more', 20 );
- function sbt_custom_excerpt_more( $output ) {return preg_replace('/<a[^>]+>Continue reading.*?<\/a>/i','',$output);
- }
- add_filter( 'get_the_excerpt', 'sbt_custom_excerpt_more', 20 );
- //* 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;
- }
- function be_custom_loop_feature() {
- global $post;
- // arguments, adjust as needed
- $args = array(
- 'post_type' => 'post',
- 'posts_per_page' => 1,
- 'post_status' => 'publish',
- 'paged' => get_query_var( 'paged' )
- );
- /*
- Overwrite $wp_query with our new query.
- The only reason we're doing this is so the pagination functions work,
- since they use $wp_query. If pagination wasn't an issue,
- use: https://gist.github.com/3218106
- */
- global $wp_query;
- $wp_query = new WP_Query( $args );
- if ( have_posts() ) :
- echo '<ul>';
- while ( have_posts() ) : the_post();
- // Return if CPT Tip of the Day
- add_action( 'genesis_after_entry_content', 'manta_tips_pre', 15 );
- function manta_tips_pre() {
- // 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="tip-excerpt"><p><div class="entry-content">';
- 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><div class="divider"></div>';
- }
- }
- endwhile;
- echo '</ul>';
- do_action( 'genesis_after_endwhile' );
- endif;
- wp_reset_query();
- }
- function be_custom_loop_teasers() {
- global $post;
- // arguments, adjust as needed
- $args = array(
- 'post_type' => 'post',
- 'posts_per_page' => 20,
- 'post_status' => 'publish',
- 'paged' => get_query_var( 'paged' )
- );
- // Use $loop, a custom variable we made up, so it doesn't overwrite anything
- $loop = new WP_Query( $args );
- // have_posts() is a wrapper function for $wp_query->have_posts(). Since we
- // don't want to use $wp_query, use our custom variable instead.
- if ( $loop->have_posts() ) :
- echo '<ul>';
- while ( $loop->have_posts() ) : $loop->the_post();
- // Return if CPT Tip of the Day
- add_action( 'genesis_after_entry_content', 'manta_tips_teaser_pre', 15 );
- function manta_tips_teaser_pre() {
- // Store the pre tips data
- $tips_data_pre = array(
- 'totd_tags' => get_field( 'totd_tags' ),
- );
- // Only output if we have tips data
- if ($tips_data_pre['totd_tags'] !='') {
- {
- echo '<div class="tip-excerpt"><p><div class="entry-content">';
- echo '<div class="entry-terms">' , do_shortcode('[post_terms taxonomy="totd_tags" before="See More Tips For: " taxonomy="totd_tags"] '),'</div>' ;
- </div></div>';
- echo '</p><div class="divider"></div>';
- endwhile;
- echo '</ul>';
- do_action( 'genesis_after_endwhile' );
- endif;
- // We only need to reset the $post variable. If we overwrote $wp_query,
- // we'd need to use wp_reset_query() which does both.
- wp_reset_postdata();
- }
- }
- }
- add_action( 'genesis_loop', 'be_custom_loop_feature' );
- add_action( 'genesis_loop', 'be_custom_loop_teasers' );
- remove_action( 'genesis_loop', 'genesis_do_loop' );
- genesis();
Advertisement
Add Comment
Please, Sign In to add comment