Get 25% off GP Premium with the discount code: BLACKFRIDAY17

Premium support

Please log in to post in these forums. If you didn't create an account when you purchased, please contact us.

Free support

If you haven't purchased GP Premium, support for the free theme can be found on WordPress.org.

[Support request] Removing Post Articles

Home Forums Support Removing Post Articles

Tagged: , ,

This topic contains 4 replies, has 2 voices, and was last updated by  Tom 1 week, 2 days ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #424325

    I am currently using ACF to create custom posts. I have a template function set up to query the posts and display them in a custom fashion. My issue is that GP is creating the articles below my custom posts where the posts would originally go. I will include a screenshot of what i mean.

    Issue Screenshot

    As you can see the post above is a custom format, but the blank ‘Posts’ are still sitting blow. Not sure how to remove these from view.

    GP Premium 1.5.2
    #424470

    Tom
    Lead Developer

    Can you show me your custom template by pasting it into a pastebin?

    #424519

    I just created a shortcode to output the ACF post.

    function hvw_one_day_custom_loop() {
    
    	$date = date('l, F n, Y');	
    
    	echo '<div class="container-fluid">'.
    		 '<div class="row title-row">'.
    		 '<div class="col-sm-12 forecast-heading">'.
    		 '<span id="forecast-title">HUDSON VALLEY, NY</span>'.
    		 '<span id="date">'. $date .'</span>'.
    		 '</div>'.
    		 '</div>'.
    		 '<div class="row weather-row">';
    
    	$args = array(
    		'posts_per_page'   => 4,
    		'order' => 'ASC',
    		'post_type' => 'one_day_forecast', 
    	);
    	global $wp_query;
    	$wp_query = new WP_Query( $args );
    	
    		if( $wp_query->have_posts() ) {
    		  while( $wp_query->have_posts() ) {
    			$wp_query->the_post();
    			
    			/* ---------------------------------------24 HOUR CONTAINER START--------------------------------------------------------*/			
    					
    
    						
    			/*-----------------TITLE---------------------*/
    			
    			echo '<div class="col-sm-3 col-md-3 col-lg-3">';
    			echo "<div class='hvw-24h-day-container'>";
    
    			echo '<div class="row"><div class="col-md-12">';
    			echo '<div class="hvw-24h-title"><p class="period">' . get_the_title() . '</p></div>';
    			echo '</div></div>';
    						
    
    			/*------------------TEMP RANGE--------------------*/
    			
    			echo '<div class="row">'.
    				'<div class="col-sm-5">';
    
    		    $low_24 = get_field('od_low_temp'); 
                $high_24 = get_field('od_high_temp'); 
    			
    				if( !empty($low_24) && !empty($high_24) ){ ?>
    
    					<div class="hvw-24h-temp-range temp"> <?php echo $high_24 . '° - ' . $low_24 . '°' ?> </div>
    
    			    <?php }
    			  
    
    			/*------------------PRIMARY WEATHER SHORT DESCRIPTION--------------------*/
    			
    									
    			$basic_weather_description_light_field = get_field_object('basic_weather_description_od_light'); 
                $basic_weather_description_light_value = get_field('basic_weather_description_od_light');
                if( !empty($basic_weather_description_light_field['choices'][ $basic_weather_description_light_value ])) {
    			$basic_weather_description_light_label = $basic_weather_description_light_field['choices'][ $basic_weather_description_light_value ];
                }
    			$basic_weather_description_dark_field = get_field_object('basic_weather_description_od_dark'); 
                $basic_weather_description_dark_value = get_field('basic_weather_description_od_dark');
                if (!empty($basic_weather_description_dark_field['choices'][ $basic_weather_description_dark_value ])) {
    			$basic_weather_description_dark_label = $basic_weather_description_dark_field['choices'][ $basic_weather_description_dark_value ];
                }	
    				if( !empty($basic_weather_description_light_value) ){ ?>
    
    					<div class="hvw-24h-weather-primary wx-phrase"> <?php echo $basic_weather_description_light_label ?> </div>
    
    			    <?php } else if( !empty($basic_weather_description_dark_value) ){ ?>
    
                        <div class="hvw-24h-weather-primary wx-phrase"> <?php echo $basic_weather_description_dark_label ?> </div>
    
    				<?php }
    				
    			echo '</div>';
    
    			/*-----------------ICON---------------------*/
    
    			echo '<div class="col-sm-7">';
    								
    		    $weather_icon_light = get_field('basic_weather_description_od_light');
    			$weather_icon_dark = get_field('basic_weather_description_od_dark');
    			  
                    if( !empty($weather_icon_light) ){ 
    
                        echo '<div class="hvw-24h-icon"><img src="http://hudsonvalleyweather.com/wp-content/themes/genesis-sample/images/new-weather-icons/' . $weather_icon_light . '.png' . 
    					'" border="0" width="75" height="75" /></div>';
    
    				} else if( !empty($weather_icon_dark) ) {
                                                
                        echo '<div class="hvw-24h-icon"><img src="http://hudsonvalleyweather.com/wp-content/themes/genesis-sample/images/new-weather-icons/' . $weather_icon_dark . '.png' . 
    					'" border="0" width="75" height="75" /></div>';
    							
    				}
    
    			echo '</div>'.
    				'</div>';
    
    			/*-------------------MAIN DESCRIPTION-------------------*/
    				
    			$detailed_weather_description_24 = get_field('od_detailed_weather'); 
    			
    			echo '<div class="row">'.
    				'<div class="col-sm-12">'.
    				'<div class="title-block"><span id="short-term">SHORT TERM</span></div>'.
    				'<div class="full-desc">';
    
    				if( !empty($detailed_weather_description_24) ){ ?>
    
    					<div class="hvw-24h-details"> <?php echo $detailed_weather_description_24 ?> </div>
    
    				<?php }
    							
    			
    			echo '</div>'.
    				'</div>'.
    				'</div>';				
    			
    			echo '</div>'.
    				'</div>';
    
    			/*--------------------------------------------24 HOUR CONTAINER END---------------------------------------------------*/	
    			
    		    } 
    		
            }	
    		wp_reset_postdata();
    		
    		echo '</div>'.
    		'</div>';
    	
        }
    
       add_shortcode('one-day-forecast', 'hvw_one_day_custom_loop');
    #424521

    I mean, i could just grab the class and display none, but i was curious if there was a more solid way.

    #424651

    Tom
    Lead Developer

    You would need to use output buffering in your shortcode: https://codex.wordpress.org/Shortcode_API#Output

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.