• Resolved janbrokes

    (@janbrokes)


    Hello I woul like te rewrite this par of code, so that it will display both published and future post

    <div class="carousel-slider-outer carousel-slider-outer-posts carousel-slider-outer-<?php echo $id; ?>">
    	<?php carousel_slider_inline_style( $id ); ?>
        <div <?php echo join( " ", $this->carousel_options( $id ) ); ?>>
    		<?php
    		$posts = carousel_slider_posts( $id );
    		foreach ( $posts as $_post ):
    			global $post;
    			$post = $_post;
    			setup_postdata( $post );
    			$category = get_the_category( $post->ID );
    
    			do_action( 'carousel_slider_post_loop', $post, $category );
    
    			$html = '<div class="carousel-slider__post">';
    			$html .= '<div class="carousel-slider__post-content">';
    			$html .= '<div class="carousel-slider__post-header">';
    			// Post Thumbnail
    			$_permalink = esc_url( get_permalink( $post->ID ) );
    			$_thumb_id  = get_post_thumbnail_id( $post->ID );
    			$_excerpt   = wp_trim_words( wp_strip_all_tags( $post->post_content ), '20', ' ...' );
    
    			// Post Title
    			$html .= sprintf( '<a class="carousel-slider__post-title" href="%s"><h3>%s</h3></a>', $_permalink, $post->post_title );
    			$html .= '</div>'; // End Post Header
          			// Post date
    			$_created  = strtotime( $post->post_date );
    			$_modified = strtotime( $post->post_modified );
    

    Have you any idea, how to rewrite it?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    It would seem that the solution is in the function that gets the posts in the first place, ‘carousel_slider_posts()’. Where is that defined?

    Thread Starter janbrokes

    (@janbrokes)

    Hello, i think its here

    if ( ! function_exists( 'carousel_slider_posts' ) ) {
    	/**
    	 * Get posts by carousel slider ID
    	 *
    	 * @param $carousel_id
    	 *
    	 * @return array
    	 */
    	function carousel_slider_posts( $carousel_id ) {
    		$id = $carousel_id;
    		// Get settings from carousel slider
    		$order      = get_post_meta( $id, '_post_order', true );
    		$orderby    = get_post_meta( $id, '_post_orderby', true );
    		$per_page   = intval( get_post_meta( $id, '_posts_per_page', true ) );
    		$query_type = get_post_meta( $id, '_post_query_type', true );
    		$query_type = empty( $query_type ) ? 'latest_posts' : $query_type;
    
    		$args = array(
    			'post_type'      => 'post',
    			'post_status'    => 'publish',
    			'order'          => $order,
    			'orderby'        => $orderby,
    			'posts_per_page' => $per_page
    		);
    

    sou could it be
    ‘post_status’ => ‘publish, future’,

    ?

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    'post_status' => array( 'publish', 'future'),

    Thread Starter janbrokes

    (@janbrokes)

    thanks it works

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘display future post’ is closed to new replies.