Support

Account

Forum Replies Created

  • To answer your question, I’m thinking it would be #2.

    Logically the event_date subfield would have to compare it’s date to today’s date and post the next upcoming event in the left column until that event date has passed. Once that has passed, then the next event date would post in the left column until it’s expiration. All other dates would be posting on the right.

    If ACF is going to be an issue with posting such a repeater in this manner, what would you recommend? A different plugin? A different ACF Field method?

  • I’m trying to have on the left column the next upcoming event and have the other events post on the right column. The left column data is what’s missing. The right column data is not having a problem posting.

    <?php if( have_rows('tradeshows', 40) ): ?>
    //This is a repeater field, and I'm getting values from another post:
    //https://www.advancedcustomfields.com/resources/how-to-get-values-from-another-post/

    ‘event_date’ is a sub field. I’ve attached screenshots of my setup.

  • I’ll try this and get back to you when I return on the project.

  • Here is the code in the entirety. The content on the right posts, but I’m still not getting the next post for the left column:

    		<?php if( have_rows('tradeshows', 40) ): ?>
                <?php
    				$current_event_date = get_sub_field('event_date');
    				$next_event_query = new WP_Query(array(
    							  'post_type'      => 'event',
    							  'post_status'    => 'publish',
    							  'posts_per_page' => -1,
    							  'meta_query'     => array(
    								array(
    								  'key'        => 'event_date',
    								  'compare'    => '>',
    								  'value'      => $current_event_date,
    								)
    							  ),
    							  'meta_key'	   => 'event_date',
    							  'orderby'        => 'meta_value',
    							  'order'          => 'ASC'
    							));
    				
    				$rows = get_field('tradeshows', 40);
    				?>
                    
    				<div class="trades">
    					<?php if ($next_event_query->have_posts()) : while ($next_event_query->have_posts()): $next_event_query->the_post(); ?>
                            <div class="col-sm-3">
                             	<h3>NEXT TRADESHOW</h3>
                                <p><?php echo $current_event_date; ?></p>
                             </div>
                     <?php wp_reset_postdata(); ?>
               		<?php endwhile; ?>
                    <?php endif; ?>
                    
                            <div class="col-sm-6 col-sm-offset-3">        
                            <h3>UPCOMING TRADESHOWS</h3>
                            <?php while( have_rows('tradeshows', 40) ): the_row();  ?>   
                                    <div class="col-sm-4">                       
                                        <p class="eventdate"><?php the_sub_field('event_date'); ?><br />
                                        <span class="locplace"><?php the_sub_field('event_location'); ?></span></p>
                                    </div>                                                          
                            <?php endwhile; ?>   
                            </div>
                     </div>                    		
          <?php endif; ?>
    </div>
  • There’s a thought. It’s worth mentioning I suppose.

    Stupid question: Will ACF ever make its own Custom Widget feature to where I can create the above scenario?

  • James,

    I’m still struggling with this type of issue and am attempting it again. The content posts but not the image still.

    Here is my info.

    functions.php:

    $backgroundimage = get_field('widget_background_image', 'text-2');
    	
    	register_sidebar( array(
    		'name'          => __( 'Content Bottom 1', 'dvkap' ),
    		'id'            => 'content-bottom',
    		'description'   => __( 'Appears at the bottom of the content on posts and pages.', 'dvkap' ),
    		'before_widget' => '<section id="%1$s" class="widget %2$s" style="background-image: url(' . $backgroundimage['url'] . ');">',
    		'after_widget'  => '</section>',
    		'before_title'  => '<h2 class="widget-title">',
    		'after_title'   => '</h2>',
    	) );

    template code:

    
    <?php
     if ( is_active_sidebar( 'content-bottom' ) ): ?> 
    		<?php dynamic_sidebar( 'content-bottom' ); ?>
    <?php endif;?>

    Custom field settings (cfsettings.jpg)

    Widget screenshot (widget.jpg)

  • With this code, I’m able to get the right column to post:

    <?php if( have_rows(‘tradeshows’, 40) ): ?>
    <?php
    $current_event_date = get_sub_field(‘event_date’);
    $next_event_query = new WP_Query(array(
    ‘post_type’ => ‘events’,
    ‘post_status’ => ‘publish’,
    ‘posts_per_page’ => -1,
    ‘meta_query’ => array(
    array(
    ‘key’ => ‘event_date’,
    ‘compare’ => ‘>’,
    ‘value’ => $current_event_date,
    ‘type’ => ‘CHAR’
    )
    ),
    ‘orderby’ => ‘meta_value’,
    ‘order’ => ‘ASC’
    ));

    $rows = get_field(‘tradeshows’, 40);
    ?>

    <?php if ($next_event_query->have_posts()) : while ($next_event_query->have_posts()): $next_event_query->the_post(); ?>
    <div class=”col-sm-3″>
    <h3>NEXT TRADESHOW</h3>
    <p><?php echo $current_event_date; ?></p>
    </div>
    <?php wp_reset_postdata(); ?>
    <?php endwhile; ?>
    <?php endif; ?>

    <div class=”col-sm-6 col-sm-offset-3″>
    <h3>UPCOMING TRADESHOWS</h3>
    <?php while( have_rows(‘tradeshows’, 40) ): the_row(); ?>
    <div class=”col-sm-4″>
    <p class=”eventdate”><?php the_sub_field(‘event_date’); ?><br />
    <span class=”locplace”><?php the_sub_field(‘event_location’); ?></span></p>
    </div>
    <?php endwhile; ?>
    </div>
    <?php endif; ?>

    I don’t understand how to create a ‘meta_key’ argument as you’ve mentioned since I need to retrieve the next post in the list. I’m assuming you mean this:

    $next_event_query = new WP_Query(array(
    							  'post_type'      => 'event',
    							  'post_status'    => 'publish',
    							  'posts_per_page' => -1,
    							  'meta_query'     => array(
    								array(
    								  'meta_key'   => 'event_date',
    								  'key'        => 'event_date',

    The below code posts the data in the right column within the loop that I have set:

    <p class="eventdate"><?php the_sub_field('event_date'); ?><br />
    <span class="locplace"><?php the_sub_field('event_location'); ?></span></p>

    So I’m still needing to understand how to post the next post in the left column.

  • I guess I’m going to take a different approach to this.

    I’ve now just assigned the Custom Field directly to a Text Widget and I’m trying to get the values that way.

    Return Value: Image URL

    Code:

    
    <?php 
    
    $image = get_field('widget_background_image', 'widget_' . $widget_id);
    
    if( !empty($image) ): ?>
    
    	<div style="background-image: url('<?php echo $image['url']; ?>');"></div>
    
    <?php endif; ?>

    Now it is my understanding that I should be seeing a background image based on this code, but all I get is the text in return and no image.

  • What I’m trying to do is the following (attachment).

    At first with my original code, the content on the right posted fine. It’s content on the left (the next post) is where I was not getting content.

    After reading your post and modifying my code, now I’m not getting ANY data posting.

    
    <?php if( have_rows('tradeshows', 40) ): ?>
                	<?php while( have_rows('tradeshows', 40) ): the_row(); ?>
    
    <?php
    $current_event_date = get_sub_field('event_date');
    							$next_event_query = new WP_Query(array(
    							  'post_type'      => 'events',
    							  'post_status'    => 'publish',
    							  'posts_per_page' => -1,
    							  'meta_query'     => array(
    								array(
    								  'key'        => 'event_date',
    								  'compare'    => '>',
    								  'value'      => $current_event_date,
    								  'type'       => 'DATE'
    								)
    							  ),
    							  'orderby'        => 'meta_value',
    							  'order'          => 'ASC'
    							));
                                $rows = get_field('tradeshows', 40);
                                $tradeshowslocation = get_sub_field('event_location', 40);
    
    if ($next_event_query->have_posts()) while ($next_event_query->have_posts()): $next_event_query->the_post(); ?>
                      
                          <div class="trades container">
                                <div class="col-sm-3">
                                    <h3>NEXT TRADESHOW</h3>
                                    <p><?php echo $current_event_date; ?></p>
                                 </div>
                                 
                                  <div class="col-sm-6 col-sm-offset-3">        
                                    <h3>UPCOMING TRADESHOWS</h3>                         
                                        <div class="col-sm-4">                       
                                            <p class="eventdate"><?php the_sub_field('event_date'); ?><br />
                                            <span class="locplace"><?php the_sub_field('event_location'); ?></span></p>
                                        </div>                                                        
                                  </div> 
                            </div>
    <?php endwhile; ?>
                      <?php  wp_reset_postdata(); ?>
    <?php endwhile; ?>
               <?php endif; ?>
  • Updated code, but still not record displaying:

               <?php if(get_field('tradeshows', 40) ): ?>
                        <div class="trades container">
                            <?php
                                // vars
    							$current_event_date = get_sub_field('event_date');
    							$next_event_query = new WP_Query(array(
    							  'post_type'      => 'events',
    							  'post_status'    => 'publish',
    							  'posts_per_page' => -1,
    							  'meta_query'     => array(
    								array(
    								  'key'        => 'event_date',
    								  'compare'    => '>',
    								  'value'      => $current_event_date,
    								  'type'       => 'DATE'
    								)
    							  ),
    							  'orderby'        => 'meta_value',
    							  'order'          => 'ASC'
    							));
                                $rows = get_field('tradeshows', 40);
    							//$tradeshowsdate = get_sub_field('event_date', 40);
                                $tradeshowslocation = get_sub_field('event_location', 40);
                        ?>
                          	<?php if ($next_event_query->have_posts()) while ($next_event_query->have_posts()): $next_event_query->the_post(); ?>
                            <div class="col-sm-3">
                             	<h3>NEXT TRADESHOW</h3>
                                <p><?php echo $current_event_date; ?></p>
                             </div>
                             <?php endwhile; ?> 
    
    <?php endif; ?>
  • Thanks for the help, James.

    I’ve managed to get it working correctly just as you’ve recommended.

  • Okay, I’ve tried the above using this method but the widget block just disappeared and doesn’t appear on ANY pages.

    <?php
    $excluded = get_field('excluded_pages_field', 1255, 1509, 1213, 1293, false);
    global $post;
    if( $excluded && !in_array($post->ID, $excluded) ){
    
    	 $eventcontent = get_field('event_content', 1368);
    	 $moredetails = get_field('more_details', 1368);
    	 $eventimage = get_field('event_image', 1368);
               
     if(!empty($eventcontent) ): ?>
    	<section class="boldSection gutter btBottomVertical btParallax">
        	<div class="specialevent" style="background:  linear-gradient(to right, rgba(255,255,255,1) 0%,rgba(255,255,255,1) 16%,rgba(255,255,255,1) 50%,rgba(255,255,255,0.01) 52%,rgba(255,255,255,0) 55%), url(<?php echo $eventimage; ?>); background-size: cover!important; background-repeat: no-repeat!important; background-position: right center!important;"> 
                <div class="col-sm-6">
                		<header class="header btDash bottomDash">
                        	<div class="dash">
                            	<h2>
                                	<span class="headline">Special Event</span>
    						 	</h2>
                        	</div>
                        </header>
                		<?php echo $eventcontent; ?>
                		<a href="<?php echo $moredetails; ?>" class="btBtn btBtn btnOutlineStyle btnAccentColor btnBig btnHalfWidth btnRightPosition btnNoIcon"><span class="btnInnerText">More Details</span></a><a href="about/season-tickets/" class="btBtn btBtn btnOutlineStyle btnAccentColor btnBig btnHalfWidth btnRightPosition btnNoIcon"><span class="btnInnerText">Get Tickets</span></a>
                	<div class="btClear btSeparator topSemiSpaced noBorder"><hr></div>
               </div>           
            </div>
       </section>
     <?php endif; ?>  
     <?php } ?>
  • Okay,
    I will try that.

    Thank you, James.

  • Well I did try this and the widget block still appears on those pages that share the same template.

  • (facepalm)
    I tend to get those two types of usages confused.

  • Yep, there were repetitious fields.

    Recreated them to be unique and all went well!

    Thank you, Mr. Huebner.

  • I’ll take a look to see if there are any repetitions.

  • When I create a new Page, the error comes back. But if I go back to the first Page that I encountered the issue, the error isn’t there.

    And it gets more interesting:
    More errors:

    Warning: Illegal string offset ‘acf_fc_layout’ …plugins/advanced-custom-fields-pro/pro/fields/flexible-content.php on line 238

  • Yes, I have.

    It must be a bug because I went into the Custom Field and deleted the fields. After rebuilding them, the issue went away.

  • Awesome!

    This is what I came up with that worked VERY well.

    <?php if( have_rows('tabs') ): ?>
    					<?php
                        
                        // vars
                        $c = 0;
                        $class = '';
                        $linkid = get_sub_field('tab_id');
                        $background = get_sub_field('background_image');
                        $title = get_sub_field('title');
                        $description = get_sub_field('content');
                        $tabs = get_field('tabs');
    					$row_count = count($tabs);
    					
    					?>
                            <div role="tabpanel" class="tab-panels largetabs">                        
                                <div class="tab-content">
                                    <div role="tabpanel" class="tab-pane fade in active">            
                                                <ul class="nav nav-tabs">
    												<?php $c = 0; ?>
    													<?php while( have_rows('tabs') ): the_row(); $c++;  ?>
    														<?php if( get_row_layout() == 'image' ):    ?>                                  
                                                                <li class="<?php if($c==1) {echo "active down-arrow"; } ?>  <?php if ($row_count==1) { echo "col-sm-12"; } elseif ($row_count==2) { echo "col-sm-6"; } elseif ($row_count==3) { echo "col-sm-4"; } elseif ($row_count==4) { echo "col-sm-3"; } elseif ($row_count==6) { echo "col-sm-2"; } ?>"  style="background: url('<?php echo the_sub_field('background_image'); ?>'); background-repeat: no-repeat; background-size: cover; background-position: top center;"><a href="#<?php echo the_sub_field('tab_id');?>" data-toggle="tab"><?php the_sub_field('title'); ?></a></li>
                                                            <?php endif; ?>
                                                        <?php endwhile; ?>
                                                </ul>
    
    												<div class="tabcontent container">   
    												<?php $c = 0; ?>
    													<?php while( have_rows('tabs') ): the_row(); $c++;  ?>                                        
                                                            <div id="<?php echo the_sub_field('tab_id');?>" class="tab-pane fade in <?php if( $c == 1 ){ echo "active"; } ?>"><?php echo the_sub_field('content'); ?></div>
                                                        <?php endwhile; ?>
                                                        </div><!--end container-->    
                                    </div><!--end tabpanel tab-pane class-->
                                <?php endif; ?><!--endif tabs rows-->
                                </div><!--end tab-content-->
                            </div><!--end tab-panels.top-->
                            
                        <?php comments_template( '', true ); ?>
                        <?php if ( is_active_sidebar( 'page-widget' ) ) : ?>
                        <?php dynamic_sidebar( 'page-widget' ); ?>
                        <?php endif; ?>
                        <?php endwhile; // end of the loop. ?>
        
    
  • I’ll look into it and get back to you.

  • Warning: Illegal string offset ‘url’ in /home/…/public_html/…/…/…/wp-content/themes/…/functions.php on line 143

    $backgroundimage = get_field('widget_background_image', 'widget_wysiwyg_widgets_widget-11');
    
    	register_sidebar( array(
    		'name'          => __( 'Widgets', 'tempestcorp' ),
    		'id'            => 'page-widget',
    		'description'   => __( 'Appears on any of the assigned pages.', 'tempestcorp' ),
    		'before_widget' => '<section id="%1$s" class="widget %2$s" style="background-image: url(' . $backgroundimage['url'] . ');">',
    		'after_widget'  => '</section>',
    		'before_title'  => '<h2 class="widget-title">',
    		'after_title'   => '</h2>',
    	) );
    
    
  • Okay, so I’ve decided to try a different tactic and am still not getting the background image to appear in the widget.

    $backgroundimage = get_field('widget_background_image', 'widget_' . $widget_id);
    
    	register_sidebar( array(
    		'name'          => __( 'Widgets', 'tempestcorp' ),
    		'id'            => 'page-widget',
    		'description'   => __( 'Appears on any of the assigned pages.', 'tempestcorp' ),
    		'before_widget' => '<section id="%1$s" class="widget %2$s" style="background-image: url(' . $backgroundimage['url'] . ');">',
    		'after_widget'  => '</section>',
    		'before_title'  => '<h2 class="widget-title">',
    		'after_title'   => '</h2>',
    	) );

    Location Rule:
    Widget = Widget Block Widget

    Inside the widget (Capture.PNG). But still no image. I am left with (Capture2.PNG).

    On top of that, the <section id=””> is stripped.

Viewing 25 posts - 1 through 25 (of 67 total)