Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Ensures all queries pull posts in ascending alpha order.
- * Called by using the pre_get_posts action within the __construct() method of this class
- */
- function alpha_posts( $query ) {
- set_query_var( 'orderby', 'title' );
- set_query_var( 'order', 'ASC' );
- }
- /**
- * Run the custom loop for archive pages
- * @uses do_action() to run the sau-contact-start-archive-loop and
- * sau-contact-done-archive-loop actions to allow output before/after
- * the loop
- */
- function archive_loop() {
- $obj = get_queried_object();
- if ( is_object( $obj ) ) {
- /*if ( property_exists( $obj, 'taxonomy' ) ) {
- $tmp = get_taxonomy( $obj->taxonomy );
- printf( '<h1>%s</h1>', $tmp->labels->name );
- }*/
- if ( property_exists( $obj, 'name' ) )
- printf( '<h1 class="%2$s">%1$s</h1>', $obj->name, apply_filters( 'sau-contact-archive-title-class', 'archive-title' ) );
- }
- $i = 0;
- global $post;
- do_action( 'sau-contact-start-archive-loop' );
- if ( have_posts() ) :
- while ( have_posts() ) : the_post();
- error_log( '[SAU Debug]: ' . $post->post_name );
- $this->do_archive_entry( $post, $i );
- $i++;
- endwhile;
- else :
- _e( apply_filters( 'sau-contact-no-posts', '<p>Sorry, no posts matched your criteria.</p>' ) );
- endif;
- do_action( 'sau-contact-done-archive-loop' );
- }
- /**
- * Output the actual content for an entry on an archive page
- * @param stdClass $post the WordPress post object
- * @param int $i a counter for determining which class to assign
- */
- function do_archive_entry( $post = null, $i = 0 ) {
- echo $this->get_archive_entry( $post, $i );
- }
- function get_archive_entry( $post = null, $i = 0 ) {
- if ( empty( $post ) )
- global $post;
- setup_postdata( $post );
- $title = apply_filters( 'title-wpcm-value', get_post_meta( $post->ID, 'title_wpcm_value', true ) );
- $names = array();
- $names[] = get_post_meta( get_the_ID(), 'first_name_wpcm_value', true );
- $names[] = get_post_meta( get_the_ID(), 'last_name_wpcm_value', true );
- $names = apply_filters( 'name-wpcm-value', implode( ' ', $names ), $names );
- $has_email = is_email( apply_filters( 'email-wpcm-value', get_post_meta( get_the_ID(), 'email_wpcm_value', true ) ) );
- $phone = apply_filters( 'phone-wpcm-value', get_post_meta( get_the_ID(), 'office_phone_wpcm_value', true ) );
- $d = get_the_terms( get_the_ID(), 'department' );
- $depts = array();
- foreach ( $d as $t ) {
- $depts[] = $t->name;
- }
- $depts = '<span class="departments" style="font-style: italic; display: block">' . implode( ', ', $depts ) . '</span>';
- return apply_filters( 'sau-contact-archive-entry', '
- <div class="contact' . ( $i % 2 ? ' alt' : '' ) . '">
- <span class="m-name"><a href="' . get_permalink() . '" title="' . esc_attr( $title ) . '">' . $names . '</a></span>
- <span class="m-email">' . ( $has_email ? '<a href="mailto:' . $has_email . '">' . $has_email . '</a>' : ' ' ) . '</span>
- <span class="m-mobile"><span>870-235-' . $phone . '</span> (O)</span>
- <span class="title">' . $title . '</span>
- ' . $depts . '
- </div>' );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement