Support

Account

Home Forums Search Search Results for 'field not displaying'

Search Results for 'field not displaying'

reply

  • Hi @emmaee

    Just to confirm, are you saying that all get_field / the_field calls are returning the correct data in both view, but the gallery field data is not being returned in one of the views?

    I wonder if your theme is using a custom filter on the post meta which is causing ACF to fail loading the value. Potentially it is only for the custom field name of ‘photos’.

    Perhaps you could create another gallery field with a different name and try that.

  • Actually, I believe what you want to do may be possible. I have run into a similar need.

    In my case I have a custom post type and in that post the user can set the item as either active or inactive. When they select inactive they are then shown a select box where they can select an alternate item to use in its place. I could have used the Post Object or Relationship type field for this, however, this would allow them to select another item that was also inactive. I did not want to do this because it would just confuse them and make them do the work of selecting an active item.

    Then I found this tutorial: Dynamically populate a select field’s choices
    http://www.advancedcustomfields.com/resources/tutorials/dynamically-populate-a-select-fields-choices/

    (sorry for the long link, for some reason the editor would not allow me to add the link the right way.)

    Anyway, the tutorial shows you how to use an options field to populate a select box. However, with a little work I was able to change it to a query to get only the items that are marked as active and built my own select that way. I have found this useful several times with the current project I’m working on.

    You might be able do the something similar but in your case you can create a query that gets a list of the projects and then a loop to pull the list of images in each project. Then your user could select from that. Unfortunately there might be more work because you would only be able to add text to the select field to choose from and I don’t think you can show the actual images in the select field so it may not be a perfect workaround.

  • I think the problem might be I’m not sure where your code should be added in order for me to test the variables. I’ve probably complicated things by (ironically) trying to display a simplified code example. The full and complete code is below.

      <?php $post_objects = get_field('right_1'); if( $post_objects ): ?>
      <div class="promoWrapper">
        <div class="promoBox clearfix">
        	<?php $post_objects = get_field('right_1'); if( $post_objects ): ?>
    				<?php foreach( $post_objects as $post_object): ?>
              <h2>
                <?php if(get_field('pb-link', $post_object->ID) != ""): ?> <!-- Gets the link for the promo box -->
                  <a href="<?php the_field('pb-link', $post_object->ID); ?>">
                <?php endif; ?><!-- pb-link ENDS -->
                <?php if(get_field('alternative_title', $post_object->ID) != ""): ?><!-- Gets the alternative title if there is one -->
                  <?php the_field('alternative_title', $post_object->ID); ?>
                <?php else : ?>
                  <?php echo get_the_title($post_object->ID); ?>
                <?php endif; ?><!-- alternative_title ENDS -->
                <?php if(get_field('pb-link', $post_object->ID) != ""): ?></a><?php endif; ?>
              </h2>
              <?php if(get_field('pb-image', $post_object->ID) != ""): ?>
              <a href="<?php the_field('pb-link', $post_object->ID); ?>">
              <img src="<?php the_field('pb-image', $post_object->ID); $size = "promo-box" ?>" class="promoImage" alt="<?php echo get_the_title($post_object->ID); ?>" title="<?php echo get_the_title($post_object->ID); ?>" />
              </a>
              <?php endif; ?><!-- pb-image ENDS -->
              <div><?php the_field('pb-content', $post_object->ID); ?></div>
              <?php if(get_field('pb-link', $post_object->ID) != ""): ?><span><a class="moreLink" href="<?php the_field('pb-link', $post_object->ID); ?>">More...</a></span><?php endif; ?>
              
          
              <!-- If the promo box is showing latest news or reports -->    
              <?php if(get_field('latest_news_or_reports', $post_object->ID) == "news"): ?>
                <?php query_posts( array ('posts_per_page' => 5, 'order'=> 'DESC', 'orderby' => 'date', 'category__in' => '' ) ); ?> 
                <?php if(have_posts()) : while(have_posts()) : the_post(); ?>   
                  <li class="title"><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></li>     		
                  <?php endwhile; ?>
                <?php endif; wp_reset_query(); ?>          
              <?php endif; ?><!-- News/Reports promoBox ENDS -->          
              
              
            <?php endforeach; ?>
          <?php endif; ?>
        </div><!-- .promoBox ENDS -->
      </div><!-- .promoWrapper ENDS -->
      <?php endif; ?><!-- right_1 ENDS -->
  • Yes, I mean category.php is using code from content-project.php to display a preview of a custom post type. archive-project.php is also using this same code from content-project.php to display the same preview on an archive page. They are both pulling the template code via get_template_part('content', 'project');. Every field for a project cpt can be displayed except the gallery field when viewing a category. That is the only field that doesn’t work, and only when viewing a category.

  • Hi @bloom

    Unfortunately, it is not possible to select a custom field value from another post object.

    This would make for a great field type, but it does not yet exist.

  • Thanks for any assistance on displaying the Datepicker date as July 19, 2013 and not 20130719.

    Let me know if there’s other documentation I should be looking at besides http://www.advancedcustomfields.com/resources/field-types/date-picker/

    Thanks!

  • Sorry but I’m not having luck with getting the date formatting to work, referring to the datepicker documentation page.

    http://www.advancedcustomfields.com/resources/field-types/date-picker/

    Here’s my code:

    if(get_field('deadline'))
    	{
    	echo '<li><strong>Deadline: </strong>' . get_field('deadline') . '</li>';
    	}	

    I was trying this but end up with a blank page:

    if(get_field('deadline'))
    	{
            $date = DateTime::createFromFormat('Ymd', get_field('deadline'));
    	echo '<li><strong>Deadline: </strong>' . $date->format('d-m-Y') . '</li>';
    	}	

    Thanks for any help!

  • I believe so. That outputs an empty array. The name ‘photos’ must be correct since they display fine on the archive page.

    If I replace the ‘photos’ with any other custom field name for that post, that displays fine.

    If I don’t use the $post->ID parameter, the photos still display fine on the archive page, but not for the category pages.

    I tried moving the code from the content-project.php template to both the archive and category pages, still no changes.

    Why would two pages, using the same code, display one custom field differently?

  • Thank you. That’s very help ful and has given a better understaning @ what I’m trying to do here.

    Just not sure what the issue is that I’m having.

    Have tried wrapping the

    <?php the_field('exchange_type'); ?>

    with
    <?php while ( have_posts() ) : the_post(); ?>'

    and

    <?php endwhile; ?>

    with differing results. When it is wrapped directly around thefield code it displays nothing, when wrapped around the whole div it displays the listings twice, but again doesn’t show the out put to the field.

    Without that code it shows the field result, but repeats the value for the first entry in a loop for the other entries.

    Hoping somebody could @ least give us a lead as to a way forward.

    Thank you

  • Have you debugged the get_field functiuon?

    
    $images = get_field('photos', $post->ID );
    
    <pre><?php var_dump($images); ?></pre>
    
  • I don’t know if this will help, but I printed the values using two methods: get_fields and get_post_custom.

    get_fields:

    <?php $fields = get_fields( $post->ID );?>
    <pre> <?php var_dump($fields) ?> </pre>

    Printed:

    ["photos"]=>
    array(0) {
    }

    get_post_custom:

    <?php $images = get_field(‘photos’, $post->ID );?>
    <pre><?php $c = get_post_custom(); var_dump($c); ?></pre>

    Printed:

    ["photos"]=>
    array(1) {
    [0]=>
    string(62) “a:4:{i:0;s:3:”123″;i:1;s:3:”125″;i:2;s:3:”124″;i:3;s:3:”126″;}”
    }
    ["_photos"]=>
    array(1) {
    [0]=>
    string(19) “field_51dad81f8f6b2″
    }
  • Hi @emmaee

    Have you printed the value of $post->ID to test that it is correct (not the get_field value, just the $post->ID)?

  • Yes, I have tested that as well, and it is correct. I also used this code to display the values of all the fields:

    $fields = get_fields( $post->ID );?>
    		<pre> <?php var_dump($fields) ?> </pre>

    I then compared the output on both the archive page and category pages. Everything is the same except on the archive page, the “photos” field shows an array filled with different photos and sizes, whereas the output on the category pages has a completely empty array.

    ["photos"]=>
      array(0) {
      }
  • Sorry @yasir.shinedezign, is not clear what you say…

    Please check this page http://www.advancedcustomfields.com/resources/field-types/image/ for documentation on how to get a value from a file/image field.

  • Hi again- thanks for your patience. I am not whether I saved or updated but this is what I found-
    archive-reports.php

    <?php
    /**
     * The template for displaying Archive pages.
     *
     * Used to display archive-type pages if nothing more specific matches a query.
     * For example, puts together date-based pages if no date.php file exists.
     *
     * Learn more: http://codex.wordpress.org/Template_Hierarchy
     *
     */
    
    get_header(); ?>
    
    <div id="main_container">
    
    <!-- IE7 float fix --><!--[if lt IE 7]><span class="iefix">.</span><![endif]-->
    
    	<div class="main">
    	
    		<div class="entries_full">
    		
    			<div class="entry_full">
    			
    				<div class="box_twothirds mt30 pr60">
    
    					<?php if (have_posts()) : while ( have_posts() ) : the_post(); ?>
    
    					<?php 
    
    					$country = get_the_term_list( $post->ID, 'report_country','', ', ', '' );
    					$year = get_the_term_list( $post->ID, 'report_year','', ', ', '' );
    					$topics = get_the_term_list( $post->ID, 'report_topic','', ', ', '' );
    
    					?>
    		 
    		 			<?php $count++; if($count > 3) { $count = 1; } ?>
    	 
    					<h4 class="<?php if($count > 1) echo "mt25 "; ?>mb12"><?php the_title(); ?></h4>
    					<?php the_content(); ?>
    					<ul class="files">
    					<?php
    						$rows = get_field('attachments');
    
    						if($rows)
    						{
    							foreach($rows as $row)
    							{
    							?>
    
    							<li>
    								<a href="<?php echo $row['file']; ?>">
    									<?php echo $row['title']; ?>	
    								</a>
    							</li>
    				
    							<?php
    							}
    						}
    					?>
    					</ul>
    					<p class="meta">
    						<?php if($country) echo 'Country: ' . $country . '<br>'; ?>
    						<?php if($year) echo 'Year: ' . $year . '<br>'; ?>
    						<?php if($topics) echo 'Topics: ' . $topics . '<br>'; ?>
    					</p>
    					<div class="bar mt25 mb30"></div>
    					
    					<?php endwhile;
    	  				
    	  				if(function_exists('wp_pagenavi')) { 
    	  					wp_pagenavi(); 
    	  				}
    	 				else { 
    						if (  $wp_query->max_num_pages > 1 ) :
    							next_posts_link( __( '&larr; Older posts', 'amplify' ) );
    							previous_posts_link( __( 'Newer posts &rarr;', 'amplify' ) );
    						endif;
    					}
    					
    					else : ?>
    					<h1><?php _e( 'Not Found', 'amplify' ); ?></h1>
    					<p><?php _e( 'Apologies, but no results were found for that search.', 'amplify' ); ?></p>
    
    					<?php endif; ?>
    
    				</div>
    
    				<!-- Begin Sidebar -->
    				<?php include('sidebar-reports.php'); ?>
    				<!-- end sidebar -->
    						
    				<div class="clear"></div>
    
    			</div><!-- end div.entry -->
    			
    		</div><!-- end div.entries -->
    
    		<div class="clear"></div>
    		
    	</div><!-- end div#main -->
    	
    	<div class="clear"></div>
    	
    </div><!-- end div#main_container-->
    
    <?php get_footer(); ?>

    I also found single-reports.php

    <?php
    /**
     * The Template for displaying all single posts.
     *
     */
    
    get_header(); ?>
    
    <div id="main_container">
    
    <!-- IE7 float fix --><!--[if lt IE 7]><span class="iefix">.</span><![endif]-->
    
    	<div class="main">
    	
    			<div class="entries_full">
    			
    				<div class="entry_full">
    				
    <?php
    $portfolio_cat = get_option('bb_portfolio_cat');
    if($portfolio_cat == 'Choose a category') {$portfolio_cat = 'portfolio';}
    if ( in_category($portfolio_cat) ) {
    include ('portfolio_single.php');
    }
    else {
    ?>
    				
    				<div class="box_twothirds mt30 pr60">
    				
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    
    				<?php 
    
    					$country = get_the_term_list( $post->ID, 'report_country','', ', ', '' );
    					$year = get_the_term_list( $post->ID, 'report_year','', ', ', '' );
    					$topics = get_the_term_list( $post->ID, 'report_topic','', ', ', '' );
    
    					?>
    		 
    		 			<?php $count++; if($count > 3) { $count = 1; } ?>
    	 
    					<h4 class="<?php if($count > 1) echo "mt25 "; ?>mb12"><?php the_title(); ?></h4>
    					<?php the_content(); ?>
    					<ul class="files">
    					<?php
    						$rows = get_field('attachments');
    
    						if($rows)
    						{
    							foreach($rows as $row)
    							{
    							?>
    
    							<li>
    								<a>">
    									<?php echo $row['title']; ?>	
    								</a>
    							</li>
    				
    							<?php
    							}
    						}
    					?>
    					</ul>
    					<p class="meta">
    						<?php if($country) echo 'Country: ' . $country . '<br>'; ?>
    						<?php if($year) echo 'Year: ' . $year . '<br>'; ?>
    						<?php if($topics) echo 'Topics: ' . $topics . '<br>'; ?>
    					</p>
    					<div class="bar mt25 mb30"></div>
    				
    <?php endwhile; // end of the loop. ?>
    
    				</div>
    
    <!-- Begin Sidebar -->
    <?php include('sidebar-reports.php'); ?>
    <!-- end sidebar -->
    							
    				<div class="clear"></div>
    				
    <?php } ?>	<!-- end single post content -->
    
    				</div><!-- end div.entry -->
    				
    			</div><!-- end div.entries -->
    
    	<div class="clear"></div>
    		
    	</div><!-- end div#main -->
    	
    	<div class="clear"></div>
    	
    </div><!-- end div#main_container-->
    
    <?php get_footer(); ?>
  • This combination output the label correctly, thanks for the pointers.

    <?php
    /*
    *  Displaying a single value's Label
    */
    $field = get_field_object('color');
    $value = get_field('color');
    $label = $field['choices'][ $value ];
    ?>

    Another question on the same issue has raised though. I have a page, with a colorscheme set as described above, also within the page, I have a Repeater Field, which has a sub-field to set a colorscheme.

    I’d like to use the same set of color options I’ve set in Options. This works fine if the sub field is named “color”, as this will pick up the choices for a select list. But when these are output, things get confused between the pages colorcheme, and the repeater field box colorscheme – both of which come from a field called “color”.

    Is it possible to have a page and a repeater field using the same Options data source for a select list?

    Thanks.

  • Thanks for this.

    I’m still outputting nothing for the label though. With this block of code, I can happily output the $color_scheme_parent variable, which is the value set from the select list, but not the label:

    <?php
    /*
    *  Displaying a single value's Label
    */
    $field = get_field_object('color');
    $value = get_field('color_scheme_color');
    $label = $field['choices'][ $value ];
    ?>
    
    <p>Color label: <?php echo $label; ?> Parent color: <?php echo $color_scheme_parent; ?></p>
  • Hi again @flashpunk! I dug into my local MU setup and confirmed how ACF operates across MU sites.

    The attached screenshot details a 4-site MU setup, and the primary site has a single post with a single text ACF with the contents “derp” in it. As we can see from the database queries on the right, the string was only found in the primary MU install site and not the others… so I guess this confirms the idea that ACF data is independent across MU sites.

    You’ve undoubtedly already checked this out, but can we confirm that the missing slider button text actually exists from the admin? Have you tried deleting that particular ACF field and re-creating it and adding the text again?

    Debugging without code/db access is indeed a bit harder 🙂

  • I’m not exactly sure where this is supposed to go, so forgive the ignorance but if placed above or between any of the following nothing is returned:

    <?php if(get_field('latest_news_or_reports', $post_object->ID) == "news"): ?>
      <?php query_posts( array ('posts_per_page' => 5, 'order'=> 'DESC', 'orderby' => 'date', 'category__in' => '' ) ); ?> 
      <?php if(have_posts()) : while(have_posts()) : the_post(); ?> 

    If placed below I get:

    Array
      (
      	[36] => stdClass Object
      (
        [term_id] => 36
        [name] => Events
        [slug] => events
        [term_group] => 0
        [term_taxonomy_id] => 36
        [taxonomy] => category
        [description] => 
        [parent] => 0
        [count] => 3
        [object_id] => 2470
      )
    
    )

    Which seems to indicate its grabbing the details from the most recent post (which is something in the Events category with an ID of 2470).

  • Well then… do you have access to the databases? I’m not terribly familiar with MU setup, but I do seem to recall that the original database gets cloned and set up for each new site.

    I’m checking out a test install of MU right now, but maybe you can answer faster – are the same custom fields available across all of the MU sites in the admin section, and is it possible to set up a new field in one MU site and not have it visible in a different site? If yes, it might be a good idea to check all of the MU sites and make sure that they all have the same fields… and then go and re-save/update the sliders and their text values.

  • It would have been AFTER the WPMU setup was done – if the other fields (there are about 20 on that page template – including ones using the repeater plugin)

  • Hah, yes that is always challenging.

    Ah, you say you added that particular field later in development… was that before or after the WPMU setup? I wonder if the databases aren’t exactly the same.

  • I unfortunately don’t have direct access to the files (security) so I can’t easily run tests like that. And I haven’t been able to reproduce it on a staging server, and another development server.

    I understand that this makes it even more difficult…

  • It would be interesting to see if the data is actually being loaded into the slide object.

    Debug! Commented / hidden dump:

    <?php echo 'ID: '.$post->ID.'<!-- '.print_r($slider, true).' -->'; ?>

    … or wide-open visibility:

    <?php echo '<pre>ID: '.$post->ID.' - '.print_r($slider, true).'</pre>'; ?>

    2 uses here: confirm that $post->ID is the one that we need, and dump all of the $slider data into a visible array. is [slide_button_text] being populated where it should?

    Troubleshooting suggestions from the bottom up I guess. Oh, and place those after you load the $slider object, obviously 😀

  • Haven’t checked the error logs, but will look into that – thats a good suggestion.

    – Yeah the rest of the info is displaying just fine…

    The slides are being called (shortened):

    <?php
    $slider = get_field('slider');
    
    foreach($slider as $slide) :
    	$slide_button_text = $slide['slide_button_text'];
    ?>

    etc etc….

    Same set of code for both links as well, it’s just masking the sub folder…

    This site is using the WPMU plugin as well.
    The only other thing I can think of is that we had added this “slide button text” field much later in development. Don’t know if that would be the cause..

    Here are some links where it’s WORKING – so for some reason it’s just effecting that one post…
    http://inspiration.travelalerts.ca/discover-st-vincent/
    http://www.travelalerts.ca/inspiration/discover-st-vincent/

    http://inspiration.travelalerts.ca/fr/sepaq-camping/
    http://www.travelalerts.ca/inspiration/fr/sepaq-camping/

    http://inspiration.travelalerts.ca/fr/sepaq-chalets/
    http://www.travelalerts.ca/inspiration/fr/sepaq-chalets/

    http://inspiration.travelalerts.ca/fr/sepaq-parcs/
    http://www/travelalerts.ca/inspiration/fr/sepaq-parcs/

    http://inspiration.travelalerts.ca/fr/sepaq-peche/
    http://www.travelalerts.ca/inspiration/fr/sepaq-peche/

Viewing 25 results - 476 through 500 (of 508 total)