- This topic has 4 replies, 2 voices, and was last updated 6 years ago by
Tom.
Viewing 5 posts - 1 through 5 (of 5 total)
-
AuthorPosts
-
November 14, 2017 at 12:00 pm #424325
Dillon
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.
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.
November 14, 2017 at 3:54 pm #424470Tom
Lead DeveloperLead DeveloperCan you show me your custom template by pasting it into a pastebin?
November 14, 2017 at 5:38 pm #424519Dillon
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');
November 14, 2017 at 5:46 pm #424521Dillon
I mean, i could just grab the class and display none, but i was curious if there was a more solid way.
November 14, 2017 at 10:54 pm #424651Tom
Lead DeveloperLead DeveloperYou would need to use output buffering in your shortcode: https://codex.wordpress.org/Shortcode_API#Output
-
AuthorPosts
Viewing 5 posts - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.