'; if ( ! empty( $headline ) || ! empty( $subheadline ) ) { $output .= '
'; if ( ! empty( $headline ) ) { $output .= '

' . wp_kses_post( $headline ) . '

'; } if ( ! empty( $subheadline ) ) { $output .= '
' . wp_kses_post( $subheadline ) . '
'; } $output .= '
'; } $output .= '
'; $output .= personaltrainer_post_page_category_service(); $output .= '
'; } echo $output; } endif; add_action( 'personaltrainer_service', 'personaltrainer_service_display', 10 ); if ( ! function_exists( 'personaltrainer_post_page_category_service' ) ) : /** * This function to display featured posts content * * @param $options: personaltrainer_theme_options from customizer * * @since Personal Trainer 0.1 */ function personaltrainer_post_page_category_service() { global $post; $quantity = get_theme_mod( 'personaltrainer_service_number', 3 ); $no_of_post = 0; // for number of posts $post_list = array();// list of valid post/page ids $type = get_theme_mod( 'personaltrainer_service_type', 'category' ); $output = ''; $args = array( 'orderby' => 'post__in', 'ignore_sticky_posts' => 1 // ignore sticky posts ); $args['post_type'] = 'ect-service'; for ( $i = 1; $i <= $quantity; $i++ ) { $post_id = get_theme_mod( 'personaltrainer_service_cpt_' . $i ); if ( $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 ) ); $no_of_post++; } } $args['post__in'] = $post_list; if ( 0 === $no_of_post ) { return; } $args['posts_per_page'] = $no_of_post; $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 ); $post_style = ( $i % 2 ) ? 'content-left' : 'content-right'; $output .= '
'; $output .= '
'; if ( get_theme_mod( 'personaltrainer_service_enable_title', 1 ) ) { $output .= the_title( '

', '

', false ); } $content_show = get_theme_mod( 'personaltrainer_service_show', 'excerpt' ); if ( 'excerpt' === $content_show ) { //Show Excerpt $more_tag_text = get_theme_mod( 'personaltrainer_excerpt_more_text', esc_html__( 'Continue reading', 'personal-trainer' ) ); $output .= '

' . get_the_excerpt() . '

'; } elseif ( 'full-content' === $content_show ) { //Show Content $content = apply_filters( 'the_content', get_the_content() ); $content = str_replace( ' )]>', ' )]>', $content ); $output .= '
' .wp_kses_post( $content ) . '
'; } // Default value if there is no first image $image = trailingslashit( esc_url ( get_template_directory_uri() ) ) . 'assets/images/no-thumb-760x760.jpg" >'; if ( has_post_thumbnail() ) { $image = get_the_post_thumbnail_url( $post->ID, 'personaltrainer-service' ); } else { // Get the first image in page, returns false if there is no image. $first_image = personaltrainer_get_first_image( $post->ID, 'personaltrainer-service', '', true ); // Set value of image as first image if there is an image present in the page. if ( $first_image ) { $image = $first_image; } } $output .= '
'; $output .= '
' . the_title( '', '', false ) . '
'; $output .= '
'; } //endwhile wp_reset_postdata(); return $output; } endif; // personaltrainer_post_page_category_service