Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'genesis_before_post_content', 'trailer_meta_content' );
- /**
- * Show trailer meta content.
- *
- * @since 1.0
- * @author Gary Jones
- *
- * @global stdClass $post WP Post object
- * @global string $prefix
- * @return null Returns null if post type is not "trailer"
- */
- function trailer_meta_content() {
- global $post, $prefix;
- // If not our trailer post type, bail out
- if ( 'trailer' != get_post_type() )
- return;
- // Set up grabbing the attributes and their outputs.
- // You should wrap each string in __() for translations.
- // Also check out genesis_get_custom_field().
- $attributes = apply_filters( 'trailer_attributes', array(
- array( get_custom_field( $prefix . 'inventory_number' ), 'Inventory Number: %1$s<br /><a href="/contact?inventory=%1$s" title="contact us about this equipment">Contact us about this equipment</a>' ),
- array( get_the_term_list( $post->ID, 'status', 'New/Used: ', ' ', '' ), '%s' ),
- array( get_the_term_list( $post->ID, 'classification', 'Classification: ', ' ', '' ), '%s' ),
- array( get_custom_field( $prefix . 'year' ), 'Year: %s' ),
- array( get_the_term_list( $post->ID, 'manufacturer', 'Manufacturer: ', ' ', '' ), '%s' ),
- array( get_the_term_list( $post->ID, 'type', 'Type: ', ' ', '' ), '%s' ),
- array( get_custom_field( $prefix . 'compartments' ), 'Compartments: %s' ),
- array( get_the_term_list( $post->ID, 'material', 'Material: ', ' ', '' ), '%s' ),
- array( get_custom_field( $prefix . 'location' ), 'Location: %s' ),
- array( get_custom_field( $prefix . 'capacity' ), 'Capacity: %s' ),
- array( get_custom_field( $prefix . 'code' ), 'Code: %s' ),
- ), $post, $prefix );
- // Loop through the attributes, assigning to an array
- foreach ( $attributes as $attribute ) {
- if ( $value = $attribute[0] )
- $output[] = esc_html( sprintf( $attribute[1], $value ) );
- }
- // Grab the first attachment if there is one
- $args = array(
- 'post_type' => 'attachment',
- 'post_mime_type' => array( 'application/doc', 'application/pdf' ),
- 'numberposts' => 1,
- 'post_status' => null,
- 'post_parent' => $post->ID
- );
- $attachments = get_posts( $args );
- // Add the first attachment to our output array
- foreach ( $attachments as $attachment ) {
- $output[] = '<a href="' . esc_url( wp_get_attachment_url( $attachment->ID ) ) . '">Download Spec Sheet</a>';
- }
- // Echo the attributes, each on a new line, and wrapped in a div if there is anything to output.
- if ( $output = implode( '<br />', $output ) )
- echo '<div id="trailer-specifications">' . $output . '</div>';
- if ( has_post_thumbnail() )
- printf( '<a href="%1$s" title="%2$s" rel="shadowbox">%3$s</a>',
- esc_url( wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' ) ),
- esc_attr( the_title_attribute( 'echo=0' ) ),
- esc_html( the_post_thumbnail( 'thumbnail' ) )
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement