Support

Account

Forum Replies Created

  • Same here, reverted back to 5.5.11

  • @eileen.schmidtke Glad I helped and the code ends up cleaner and minimal:) Just mark the topic as solved. Cheers!

  • Check code errors:
    Remove $h1 = true after the second “while” for the download links. See if it works like this.

    <div class="quick-link-sidebar">	
    
    	<?php if( have_rows('pro_resource_url') || have_rows('pro_resource_download') ): ?>
    	
      			<?php 
    				$h1 = true; // add a simple boolean set to true
    				// loop through the rows of data
    			    while ( have_rows('pro_resource_url') ) : the_row(); ?>
    
    			    <?php $quick_link_column = get_sub_field('quick_link');  ?>
    					
    					<?php if ( $h1 && $quick_link_column == "yes" ) { ?>
    
    					<h1>Quicklinks</h1>
    
    					<ul class="resource-links">
    
    					<?php $h1 = false; //now $h1 goes before this "if" condition closing bracket and it's set to false to limit the conditional only to the first link ?>
    				    <?php } ?>
    
    				    
    					<?php if ( $quick_link_column == "yes" ) { // Continue with all the links ?>						
    				     	<li class="<?php echo the_sub_field('indy_content'); ?>">
    				     		<a href="<?php the_sub_field('pro_url'); ;?>"><?php the_sub_field('pro_resource_url_name'); ?></a>
    				     	</li>
    
    			        <?php } else {
    					// something else
    			        } ?>
    
    			        </ul>
    			     
    			<?php endwhile; ?>
    			<?php wp_reset_postdata(); ?>
    
    			<?php  	// loop through the rows of data
    			    while ( have_rows('pro_resource_download') ) : the_row();?>
    
    					<?php if ( $h1 && $quick_link_column == "yes" ) { ?>
    
    					<h1>Quicklinks</h1>
    					
    					<ul class="resource-links">
    														
    					<?php $h1 = false; ?>
    			        <?php } ?>
    
    					<?php if ( $quick_link_column == "yes" ) { // Continue with all the links ?>	
    					<li class="<?php echo the_sub_field('indy_content'); ?>">
    							<a href="<?php the_sub_field('pro_download_link'); ;?>"><?php the_sub_field('pro_download_name'); ?></a>
    					</li>
    
    			        <?php } else {
    					// something else
    			        } ?>
    			     
    			<?php endwhile; ?>
    			<?php wp_reset_postdata(); ?>
    			<?php if ($h1) { } else { ?>
                               </ul>
    			<?php } ?>
    			
    			<?php endif; ?>
    
    </div><!-- end Quicklinks Sidebar -->
  • Hi @eileen.schmidtke
    I made a few changes to the code and some corrections. First the $h1 set to “false” goes before the closing bracket of the if statement so it will apply only in that condition. The first condition checks if the $h1 is “true” AND if there is any $quick_link_column that is set to “yes”. If that condition applies we display the <h1> and the opening of the ul and set the $h1 variable to false, so it applies only once. I removed the following link’s lis code to prevent the first link from showing twice.

    Next we check if there is only any $quick_link_column that is set to “yes” and display the links.

    Same goes for the pro_resource_download.

    Please test with three possible case. If there are only pro_resource_url, if there are only pro_resource_download if there are both.

    Please notice that closing should be inside the else condition brackets otherwise it will always through a closing and that’s invalid html markup. I correct it that too.

    Hope this helps!

    <div class="quick-link-sidebar">	
    
    	<?php if( have_rows('pro_resource_url') || have_rows('pro_resource_download') ): ?>
    	
      			<?php 
    				$h1 = true; // add a simple boolean set to true
    				// loop through the rows of data
    			    while ( have_rows('pro_resource_url') ) : the_row(); ?>
    
    			    <?php $quick_link_column = get_sub_field('quick_link');  ?>
    					
    					<?php if ( $h1 && $quick_link_column == "yes" ) { ?>
    
    					<h1>Quicklinks</h1>
    
    					<ul class="resource-links">
    
    					<?php $h1 = false; //now $h1 goes before this "if" condition closing bracket and it's set to false to limit the conditional only to the first link ?>
    				    <?php } ?>
    
    				    
    					<?php if ( $quick_link_column == "yes" ) { // Continue with all the links ?>						
    				     	<li class="<?php echo the_sub_field('indy_content'); ?>">
    				     		<a href="<?php the_sub_field('pro_url'); ;?>"><?php the_sub_field('pro_resource_url_name'); ?></a>
    				     	</li>
    
    			        <?php } else {
    					// something else
    			        } ?>
    
    			        </ul>
    			     
    			<?php endwhile; ?>
    			<?php wp_reset_postdata(); ?>
    
    			<?php  	// loop through the rows of data
    			    while ( have_rows('pro_resource_download') ) : the_row();
    					$h1 = true; // add a simple boolean set to true ?>
    
    					<?php if ( $h1 && $quick_link_column == "yes" ) { ?>
    
    					<h1>Quicklinks</h1>
    					
    					<ul class="resource-links">
    														
    					<?php $h1 = false; ?>
    			        <?php } ?>
    
    					<?php if ( $quick_link_column == "yes" ) { // Continue with all the links ?>	
    					<li class="<?php echo the_sub_field('indy_content'); ?>">
    							<a href="<?php the_sub_field('pro_download_link'); ;?>"><?php the_sub_field('pro_download_name'); ?></a>
    					</li>
    
    			        <?php } else {
    					// something else
    			        } ?>
    			     
    			<?php endwhile; ?>
    			<?php wp_reset_postdata(); ?>
    			<?php if ($h1) { } else { ?>
                               </ul>
    			<?php } ?>
    			
    			<?php endif; ?>
    
    </div><!-- end Quicklinks Sidebar -->
  • Better use a URL field type that gets validated upon post publish or update so the users get an error message if the URL is not in the correct format without http:// or https:// . It’s better practice not to hardcode the http:// in your template because users usually copy links from the browsers’ address bar and http:// always gets copied and that will brake the links.

  • I think i got it now:) So the links with Quicklinks “Yes” checked appear only in the sidebar, if that’s the case I think it will be a lot simpler if you make a separate group of fields for the sidebar as Quicklinks without the need to have the True/False Yes/No condition.

    But if you have to stick with the same setup i think there is a way to conditionally show the <h1>. Please check the commented code below and test if it works:

    <div class="quick-link-sidebar">
    
    	<?php if( have_rows('pro_resource_url') || have_rows('pro_resource_download') ): ?>
     	
    			<?php  	
    				$h1 = true; // add a simple boolean set to true
    				// loop through the rows of data
    			    while ( have_rows('pro_resource_url') ) : the_row(); ?>
    
    			    <?php $quick_link_column = get_sub_field('quick_link');  ?>
    					
    					<?php if ( $h1 && $quick_link_column == "yes" ) { // The first quicklink found 'yes' will display the <h1> and will open the <ul>?>
    
    					<h1>Quicklinks</h1>			
    					<ul class="resource-links"> 
    					<li class="<?php echo the_sub_field('indy_content'); ?>">
    							<a href="<?php the_sub_field('pro_url'); ;?>"><?php the_sub_field('pro_resource_url_name'); ?></a>
    					</li>
    					<?php $h1 = false; //now set the $h1 to false so only it doesn't display multiple times ?>
    					<?php} if ( $quick_link_column == "yes" ) { // Continue with the other links ?>						
    			     	<li class="<?php echo the_sub_field('indy_content'); ?>">
    			     			<a href="<?php the_sub_field('pro_url'); ;?>"><?php the_sub_field('pro_resource_url_name'); ?></a>
    			     	</li>
    
    			        <?php } else {
    					// something else
    			        } ?>
    			     
    			<?php endwhile; ?>
    			<?php wp_reset_postdata(); ?>
    
    			<?php  	// loop through the rows of data
    			    while ( have_rows('pro_resource_download') ) : the_row();
    
    			    $quick_link_column = get_sub_field('quick_link');  ?>
    					
    					<?php if ( $h1 && $quick_link_column == "yes" ) {// Same if a download link is found here?>
    					<h1>Quicklinks</h1>			
    					<ul class="resource-links">								
    			     	<li class="<?php echo the_sub_field('indy_content'); ?>">
    			     		<a href="<?php the_sub_field('pro_download_link'); ;?>"><?php the_sub_field('pro_download_name'); ?></a>
    			        </li>
    					<?php $h1 = false; ?>
    					<?php} if ( $quick_link_column == "yes" ) { // Continue with the other links ?>	
    					<li class="<?php echo the_sub_field('indy_content'); ?>">
    							<a href="<?php the_sub_field('pro_download_link'); ;?>"><?php the_sub_field('pro_download_name'); ?></a>
    					</li>
    			        <?php } else {
    					// something else
    			        } ?>
    			     
    			<?php endwhile; ?>
    			<?php wp_reset_postdata(); ?>
    			<?php if ($h1) {//do nothing
    			}else{ ?>
    			</ul>
    			<?php endif; ?>
    			
    		
    		
    
    </div> 
    
  • Just after the Radio Button Field create whatever field you want to use to add hours etc. and on that field selected Conditional Logic ‘Yes’ and ‘Show this field if’
    and from the drop down menus:
    1 Select ‘Radio Button Field Name’
    2 Select ‘is equal to’
    3 Select ‘+add hours’

    Check the edit post page to see that when you select +add hours the field you created will show next. Hope this helps!

  • Do you mean how to get the ID or the title of the artist of the current post from the relationship field instead of using a hard coded name like in your example ‘natasha_yudina’ or you want to show only post from ‘natasha_yudina’?

    Either way you are using compare the wrong way I guess. This is purely a wordpress question.

    Change this:

    array(
            'key' => 'artist', // name of custom field
    	'value' => 'name', // matches exaclty "123", not just 123.This prevents a match for "1234" 
    			'compare' => 'natasha_yudina'
    		)

    To this:

    array(
           'key' => 'artist', // name of custom field
            'value' => 'natasha_yudina' // value of custom field
            )
  • This is a basic wordpress loop condition and not an ACF issue.
    Simply put your heading after the if condition.

    <?php if( have_rows('pro_resource_url') || have_rows('pro_resource_download') ): ?>
           <h1>Quicklink</h1>
           <ul class="resource-links">
  • If I understand this correctly you want something like a text message between the fields?
    Have you tried to use a message field from the layout field types? Will this do the trick?

  • There is nothing wrong with this code.
    Have you checked for possible misspelling of the field’s name on the back end?
    Are you using it inside a loop?

  • Do we have to use a specific field name for this, to get the previous value? I mean does this apply: get_field($field, $post_id) or we have to specify a field name like this ‘get_field(‘field_name’, $post_id)’. could you possibly write this tutorial, it would be much appreciated. Anyone found a solution on this?

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