Support

Account

Forum Replies Created

  • Hi James,
    I tried just removing the endif; but it broke the page. This is all the code added to the loop-index. What I want is any empty field to be hidden. I concentrated on the voice audio because there are very few so it is most important to hide.
    Thanks
    Rob

    // BEGIN CHRIS CUSTOM
                    $content_output  =  '<div class="entry-content" '.avia_markup_helper(array('context' => 'entry_content','echo'=>false)).'>';
                    $content_output .=  $content;
    
    if($current_post['post_type'] == "story"):
    
                    $date = get_field('contributed_on'); 
                    $y = substr($date, 0, 4);
                    $m = substr($date, 4, 2);
                    $d = substr($date, 6, 2);
                    $time = strtotime("{$d}-{$m}-{$y}");
                    $images = get_field('image_gallery');
    
    				/* $content_output .= '<div class="story-id">';
    				$content_output .=  '<span><strong>Story ID: </strong></span>'.get_post_meta( $post->ID, 'story_id', true).
    				'</br>';
                    $content_output .= '</div>';
    				
    				$content_output .= '<div class="story-contributor">';
                    $content_output .=  '<span><strong>Contributor: </strong></span>'.get_post_meta( $post->ID, 'contributor', true).'</br>';
                    $content_output .= '</div>';
                    
    				$content_output .= '<div class="story-date">';
    				$content_output .=  '<span><strong>Contributed on: </strong></span>'.date('F dS Y', $time).'</br>';
                    $content_output .= '</div>';
    				
    				$content_output .= '<div class="story-permission">';
    				$content_output .=  '<span><strong>Permission to publish: </strong></span>'.get_post_meta( $post->ID, 'permission', true).'</br>';
    				$content_output .= '</div>'; */
                   
    			   $content_output .= '<div class="story-surname">';
    			   $content_output .=  '<span><strong>Surname: </strong></span>'.get_post_meta( $post->ID, 'persons_surname', true).'</br>';
    			   $content_output .= '</div>';
    
    			   $content_output .= '<div class="story-other-names">';
    			   $content_output .=  '<span><strong>Other names: </strong></span>'.get_post_meta( $post->ID, 'other_names', true).'</br>';
    			   $content_output .= '</div>';
    
                   $content_output .= '<div class="story-related">';
                   $content_output .=  '<span><strong>Other people in this story: </br></strong></span>';
    					if( have_rows('related_people') ): while ( have_rows('related_people') ) : the_row();
    					$content_output .=  get_sub_field('first_name').' '.get_sub_field('surname').'</br>';
    					endwhile; else : endif;
                   $content_output .= '</div>';
    
    			   $content_output .= '<div class="story-places">';
                   $content_output .=  '<span><strong>Locations in this story: </br></strong></span>';
    					if( have_rows('place') ): while ( have_rows('place') ) : the_row();
    					$content_output .=  get_sub_field('place').'</br>';
    					endwhile; else : endif;
    				$content_output .= '</div>';
    
    				$content_output .= '<div class="story-text">';
    				$content_output .=  '<span></br><strong>Story: </br></strong></span>'.get_post_meta( $post->ID, 'story', true).'</br>';
    				$content_output .= '</div>';
    
    				$content_output .= '<div class="story-images">';
    				$content_output .=  '<span></br><strong>Images: </br></strong></span>';
    					if( $images ): 
    					$content_output .=  '<ul>';
    						foreach( $images as $image ):
    						$content_output .= '<li>';
    						$content_output .= '<a class="lightbox" href="'.  $image['url'].'">';
    						$content_output .= '<img src="'. $image['sizes']['thumbnail'].'" alt="'.  $image['alt'].'" title="'. $image['title'].'" />';
    						$content_output .= '</a>';
    						$content_output .= '</li>';
    						endforeach;
    					$content_output .= '</ul>';
    					endif; 
    				$content_output .= '</div>';
    
    				$story_audio = '<div class="story-audio">';
    				$story_audio .=  '<span><strong>Audio / Voice recordings: </br></strong></span>';
    					if( have_rows('voice') ): while ( have_rows('voice') ) : the_row();
    					$file = get_sub_field('voice_recording');
    					if($file){
    					$story_audio .='<a href="'. $file['url'].'" target="_blank">'.$file['title'].'</a></br>';
    					//if statement added from ACF - set all the logic within this
    					}
    
    					endwhile; else : endif;
    				$story_audio .= '</div>';
    				if (function_exists('zbp_content')) {
    						$story_audio = zbp_content($story_audio);
    				}
    				$content_output .= $story_audio;
    				$content_output .= '<div class="story-links">';
    				$content_output .=  '<span></br><strong>Links to related web content / sources: </br></strong></span>';
    					if( have_rows('sources') ): while ( have_rows('sources') ) : the_row();
    					$content_output .='<a href="'. get_sub_field('link_url').'" target="_blank">'.get_sub_field('site').'</a></br>';
    					endwhile; else : endif;
    				$content_output .= '</div>';
    endif;
    
    // END CHRIS CUSTOM
  • Hi James, Have you had a chance to check my code yet?
    Many thanks
    Rob

  • That’s what I thought. I must have done something wrong in the code. This is the code with the if statement. Can you see why it doesn’t hide when empty?
    Thanks
    Rob

    $story_audio = '<div class="story-audio">';
    $story_audio .=  '<span><strong>Audio / Voice recordings: </br></strong></span>';
    	if( have_rows('voice') ): while ( have_rows('voice') ) : the_row();
    	$file = get_sub_field('voice_recording');
    	if($file){
    	$story_audio .='<a href="'. $file['url'].'" target="_blank">'.$file['title'].'</a></br>';
    	//if statement added from ACF - set all the logic within this
    	}
    
    	endwhile; else : endif;
    $story_audio .= '</div>';
    if (function_exists('zbp_content')) {
    		$story_audio = zbp_content($story_audio);
    }
    $content_output .= $story_audio;
    $content_output .= '<div class="story-links">';
    $content_output .=  '<span></br><strong>Links to related web content / sources: </br></strong></span>';
    	if( have_rows('sources') ): while ( have_rows('sources') ) : the_row();
    	$content_output .='<a href="'. get_sub_field('link_url').'" target="_blank">'.get_sub_field('site').'</a></br>';
    	endwhile; else : endif;
    $content_output .= '</div>';
    endif;
  • Thank you very much James. I’m a bit green at this. I can’t seem to get it right. What would be the logic needed to hide if empty?
    Thanks again
    Rob

  • Thanks James,
    I copied single-story to my child theme and replaced the { with a ( like suggested. Now it starts to load and I get the following error:

    Contributor: Fatal error: Call to undefined function types_render_field() in /customers/0/4/2/goldhillmuseum.org.uk/httpd.www/shaftesbury-remembers/wp-content/themes/enfold-child/single-story.php on line 8

    Any ideas what is going on?
    Much appreciated.
    Rob

  • Hi James,

    I have set WP_DEBUG to true. The error I get when I click on an individual story is below*. I have checked the working site and the error seems to be the same except different urls. I don’t really understand what they mean so any help or advice would be most appreciated.

    This is the site giving errors:
    http://shaftesbury-remembers.goldhillmuseum.org.uk/stories/
    If all looked okay to you I am guessing you were looking at the origin site that is still working fine.

    Many thanks for your help

    Rob

    *Error:
    Notice: wp_enqueue_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /customers/0/4/2/goldhillmuseum.org.uk/httpd.www/shaftesbury-remembers/wp-includes/functions.php on line 3897 Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /customers/0/4/2/goldhillmuseum.org.uk/httpd.www/shaftesbury-remembers/wp-includes/functions.php on line 3897 Warning: session_start(): Cannot send session cache limiter – headers already sent (output started at /customers/0/4/2/goldhillmuseum.org.uk/httpd.www/shaftesbury-remembers/wp-includes/functions.php:3897) in /customers/0/4/2/goldhillmuseum.org.uk/httpd.www/shaftesbury-remembers/wp-content/themes/enfold/config-templatebuilder/avia-shortcodes/masonry_entries.php on line 32 Parse error: syntax error, unexpected ‘{‘, expecting ‘(‘ in /customers/0/4/2/goldhillmuseum.org.uk/httpd.www/shaftesbury-remembers/wp-content/themes/enfold/single-story.php on line 4

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