'; if ( ! empty( $headline ) || ! empty( $subheadline ) ) { $output .= '
'; if ( ! empty( $subheadline ) ) { $subheadline = apply_filters( 'the_content', $subheadline ); $output .= '
' . str_replace( ']]>', ']]>', $subheadline ) . '
'; } if ( ! empty( $headline ) ) { $output .= '

' . wp_kses_post( $headline ) . '

'; } $output .= '
'; } $output .= '
'; // Select content $output .= alchemist_post_page_category_service(); $output .= '
'; } echo $output; } endif; add_action( 'alchemist_service', 'alchemist_service_display', 10 ); if ( ! function_exists( 'alchemist_post_page_category_service' ) ) : /** * This function to display featured posts content * * @param $options: alchemist_theme_options from customizer * * @since Alchemist 1.0 */ function alchemist_post_page_category_service() { global $post; $quantity = get_theme_mod( 'alchemist_service_number', 3 ); $post_list = array();// list of valid post/page ids $type = 'ect-service'; $output = ''; $args = array( 'orderby' => 'post__in', 'ignore_sticky_posts' => 1 // ignore sticky posts ); //Get valid number of posts $args['post_type'] = $type; for ( $i = 1; $i <= $quantity; $i++ ) { $post_id = ''; $post_id = get_theme_mod( 'alchemist_service_cpt_' . $i ); if ( $post_id && '' !== $post_id ) { // Polylang Support. if ( class_exists( 'Polylang' ) ) { $post_id = pll_get_post( $post_id, pll_current_language() ); } $post_list = array_merge( $post_list, array( $post_id ) ); } } $args['post__in'] = $post_list; $args['posts_per_page'] = $quantity; $loop = new WP_Query( $args ); while ( $loop->have_posts() ) { $loop->the_post(); $title_attribute = the_title_attribute( 'echo=0' ); $i = absint( $loop->current_post + 1 ); $output .= '
'; // Default value if there is no first image $image = ''; if ( has_post_thumbnail() ) { $image = get_the_post_thumbnail( $post->ID, 'alchemist-service', array( 'title' => $title_attribute, 'alt' => $title_attribute ) ); } else { // Get the first image in page, returns false if there is no image. $first_image = alchemist_get_first_image( $post->ID, 'alchemist-service', array( 'title' => $title_attribute, 'alt' => $title_attribute ) ); // Set value of image as first image if there is an image present in the page. if ( $first_image ) { $image = $first_image; } } $output .= '
'. $image . '
'; $output .= the_title( '

', '

', false ); //Show Excerpt $output .= '

' . get_the_excerpt() . '

'; $output .= '
'; } //endwhile wp_reset_postdata(); return $output; } endif; // alchemist_post_page_category_service