Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Hi @jasonlosito

    Querying sub field values requires a little more code:
    http://www.advancedcustomfields.com/resources/how-to/how-to-query-posts-filtered-by-custom-field-values/#example-5

    Please take note of the extra filter needed.

    Thanks
    E

  • Hi @physalis

    Sorry mate, the above will require quite a lot of time to demonstrate the PHP needed to accomplish the task. Perhaps you could hire a web developer and brief them on the task?

    Thanks
    E

  • Hi Elliot

    It does not make a difference, the function still returns an error.
    The echo $post->ID; returns an ID of the current single post i’m viewing.

    I had and idea of making a field, true/false maybe, and assign it to post edit page with location rule. As soon as the post is selected in the Relationship field and page is updated, this true/false is getting the “true” value. Then in the widget, i can use this field in WP_Query as meta_key parameter. The schema looks like this:
    Relationship fields in Flexible Content (Page) → True/False field (Post) → Widget.

    Do you think something like this is possible using Filters?

    I just don’t have another ideas how to sort out the situation.

    Thanks again for your help.

  • Hi I’ve been trying to get run a query from a repeater field with radio buttons in an option page. I’ve tried this code, but no joy:

    <?php if(get_field('funders', 'option')):  ?>
       <?php if(get_sub_field('partner_type', 'option') == 'travel'): { ?>
        
             <h4 class="section-header">Travel Partners</h4>
    
             <?php while(has_sub_field('partner_type', 'option') == 'travel'): ?>
                <?php the_sub_field('partner_name'); ?>               
             <?php endwhile; ?>
    
         
       <?php  } endif; ?> 
    
    <?php endif;?>

    I’m not exactly sure how to run this query any hints are welcome.

    Thanks

  • And one more question. If i do it like this:

    $agency = get_field('agency');

    How can I display it’s value?

  • Quite right, thanks for having a look at the code for me.

    I modified it to use traditional syntax : rather than {} and added the endforeach but it was still limiting to current month only.

    I modified the loop to output month and one entry, and then kept the else statement the same. It not outputs month name, and all entries in chronological order. I’m not 100% sure this is the best way to achieve this, but it appears to work on the front end and doesn’t throw and php errors on the back end.
    Code:

    	    <?php
                 
                 $repeater = get_field('races');
                 foreach( $repeater as $key => $row ) :
                   
                     $column_id[ $key ] = $row['race_date'];
                   endforeach; 
                   array_multisort( $column_id, SORT_ASC, $repeater );
                   
    	       $currMonth = "start";
    	       foreach( $repeater as $row ) :
    	       
    		
    		    $date = DateTime::createFromFormat('Ymd', $row['race_date']);
    			
    			if ($currMonth != $date->format('F')) 
    				    :
    				    echo '<tr class="month"><td><h2>' . $date->format('F') . '</h2></td></tr><br>';
    				    $currMonth = $date->format('F');
    				    echo '<tr class="race">';
    				
    				       echo '<td class="cell">' . $date->format('m/d') . '</td>';
    				       echo '<td class="cell"><h2>' . $row['race_name'] . '</h2></td>';
    				       echo '<td class="cell">' . $row['race_location'] . '</td>';
    				       echo '<td class="cell">' . $row['race_gender'] . '</td>';
    			echo '</tr>';
    				    
    			else : 
    			
    			echo '<tr class="race">';
    				
    				       echo '<td class="cell">' . $date->format('m/d') . '</td>';
    				       echo '<td class="cell"><h2>' . $row['race_name'] . '</h2></td>';
    				       echo '<td class="cell">' . $row['race_location'] . '</td>';
    				       echo '<td class="cell">' . $row['race_gender'] . '</td>';
    			echo '</tr>';
    			
    			endif;
    			
    
    		endforeach; 
                   ?>
    

    Thanks for starting this thread, super helpful!

  • Ok great. Kinda have it working, but my code:

    
    <?php
    $posts = get_posts(array(
    	'post_type'		=> 'spot',
    	'posts_per_page'	=> -1,
    	'meta_query'		=> array(
    		'relation' => 'OR',
    		array(
    			'key' => 'offer_title_1',
    			'compare' => '='
    		),
    		array(
    			'key' => 'offer_title_2',
    			'compare' => '='
    		),
    		array(
    			'key' => 'offer_title_3',
    			'compare' => '='
    		)
    	)
    ));
     
    if($posts)
    {
    	foreach($posts as $post)
    	{
    		echo the_title();
    	}
    }
    ?>
    

    is pulling two posts in, one which has one of these meta values and one does not. Trying to work out why it is pulling in one correct and one incorrect.

  • Hi, thank you for your replay, sorry for pushing, have this error on the live server and need to solve it asap.

    I have contacted wpengine support they said its plugin issue and need to update it. I will contact them again

    Answer for your questions.

    1. Yes, it was working fine and just stopped to work when I added the new field.
    2. There is no other areas with this error
    3. I didn’t try that, fill free to do that on staging server
    4. I didn’t try to swap to default theme

  • Hey Elliot,

    We’re experiencing this issue as well on a site we’re developing. The new version on github has resolved the error with the wp object, but the issue still persists. The issue being the fact that no fields are being displayed on the page beneath the field that’s having issues.

    In our case it’s a filter & search field that’s looking through 10k+ posts. It seems like this query is hitting some kind of limit (probably time) that’s causing everything to go downhill from there.

    We’re doing our best to limit the scope of the posts it’s pulling in, but it’s still buggy.

    Let me know if you want access so you can poke around.

  • I see the custom section when I go to edit a product.

    [IMG]http://i61.tinypic.com/acbbck.jpg[/IMG]
    [IMG]http://i58.tinypic.com/2ivjq4g.jpg[/IMG]

  • Hi @paska72

    I have logged in and can see the issue.

    Firstly, can you please contact wpengine and ask them to take a look at the issue. I believe this is a server issue not related to ACF.

    Whilst you wait for their reply, can you answer the follow q’s?
    1. Has the options page eve worked on this install?
    2. Do any other areas of the site cause a similar server error?
    3. Have you attempted to disable all plugins to test?
    4. Have you attempted to swap to default theme?

    Thanks
    E

  • Hi @phil.owen

    I think you should read the WP docs for get_posts. This function will allow you to query the DB for posts.

    Then, you can sort them, loop over them and display any ACF data you wish.

    Thanks
    E

  • Hi @j_pocapoc

    Because there are multiple ‘modals’ on the page, you need each ‘toggle’ to refer to a separate modal.

    All you need to do is place the ‘modal’ code within another repeater field loop

    Then make sure your id’s match like so:

    
    <?php if(get_field('baby_grid')): $i = 0; ?>
    	<ul>
    	<?php while(has_sub_field('baby_grid')): $i++; ?>
    		<li style="background-color:<?php the_sub_field('box_color'); ?>"class="col-md-4"><?php the_sub_field('development_stage'); ?>, <img src="<?php the_sub_field('icon'); ?>"/><a href="#" data-toggle="modal" data-target="#myModal-<?php echo $i; ?>">toggle goes here</a>
    		</li>
    		
    	<?php endwhile; ?>
    	</ul>
    
    <?php endif; ?>
    
    <?php if(get_field('baby_grid')): $i = 0; ?>
    
    	<?php while(has_sub_field('baby_grid')): $i++; ?>
    		
    		<!-- Modal -->
    		<div class="modal fade col-md-4" id="myModal-<?php echo $i; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
    		  <div class="modal-dialog" >
    		    <div class="modal-content" style="background-color:<?php the_sub_field('box_color'); ?>">
    		      <div class="modal-header">
    		        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    		        <h4 class="modal-title" id="myModalLabel"><?php the_sub_field('development_stage'); ?></h4>
    		      </div>
    		      <div class="modal-body">
    		        <p><?php the_sub_field('main_copy'); ?></p>
    		      </div>
    		      <!-- <div class="modal-footer">
    		        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    		        <button type="button" class="btn btn-primary">Save changes</button>
    		      </div> -->
    		    </div>
    		  </div>
    		</div>
    		
    	<?php endwhile; ?>
    	
    <?php endif; ?>
    
  • Hi @tienvijf

    I highly suggest taking a few minutes to research PHP debugging techniques such as print_r.

    Then debug your code line by line to fin dout at which point it is not as expected.

    Thanks
    E

  • The ACF Export Screen under the PHP section says:

    Registered field groups will not appear in the list of editable field groups.

    So I think you’ve got it right at the end – The fields are only editable via ACF if you do the XML export & import. (I’m with you though, I’d love to be able to just have it in the functions.php!)

  • I solved it by using some CSS.

    	  		<?php 
    			$images = get_field('gallery'); 
    			$image_1 = $images[0]; 
    			?>    
    			 <?php foreach( $images as $image ): ?>
    			
    			<a href="<?php echo $image['url']; ?>" rel="fancybox"><img src="<?php echo $image_1['url']; ?>" /></a>
    		
    			<?php endforeach; ?>
    
    			<div id="slideshow_thumb_info">
    			<?php echo $image_1['title']; ?><br>
    			<?php echo $image_1['caption']; ?>
    			</div>
    #slideshow_thumb img {
    	display:none;
    	width:100%;
    	height:auto;
    }
    
    #slideshow_thumb a:first-of-type img{
    	display:block;
    }
    
    #slideshow_thumb_info {
    	color:black;
    	padding-top: 10px;
    	font-size: 10px;
    	line-height: 12px;
    
    }
  • Hi @deset

    You will need to write some custom code to make this work:
    1. Add some jQuery to listen for a change on the checkbox field
    2. On change, fire an ajax call to a custom PHP function
    3. In this PHP function, update the value via update_field

    Thanks
    E

  • I’m getting closer, I think. I’ve gotten the month names to create their own rows and cells within the table in the proper order, but now the code is limiting the results on the table to entries in the current month (February).

    What I’m trying to do is echo month name on its own row before array entries for that month, and if it is not the start of a new month, echo the entries in the array in individual TD elements.

    Any thoughts would be helpful, I think I’m just not good enough with PHP to figure this one out alone.

    
    	<table id="race-calendar">
    	    <thead>
    		<tr>
    		   <th>Date</th>
    		   <th>Race Name</th>
    		   <th>Location</th>
    		   <th>Men's/Women's/Both</th>
    		</tr>
    	    </thead>
    	    <?php
                 
                 $repeater = get_field('races');
                 foreach( $repeater as $key => $row )
                   { 
                     $column_id[ $key ] = $row['race_date'];
                   } 
                   array_multisort( $column_id, SORT_ASC, $repeater );
                   
    	       $currMonth = "start";
    	       foreach( $repeater as $row )
    	       
    		{
    		    $date = DateTime::createFromFormat('Ymd', $row['race_date']);
    			
    			if ($currMonth != $date->format('F')) 
    				    {
    				    echo '<tr><td colspan="2"><h2>' . $date->format('F') . '</h2></td></tr><br>';
    				    $currMonth = $date->format('F');
    				    }
    			else { 
    			echo '<tr class="race">';
    				
    				       echo '<td class="cell">' . $date->format('m/d') . '</td>';
    				       echo '<td class="cell"><h2>' . $row['race_name'] . '</h2></td>';
    				       echo '<td class="cell">' . $row['race_location'] . '</td>';
    				       echo '<td class="cell">' . $row['race_gender'] . '</td>';
    			echo '</tr>';
    			
    			}
    			
    
    		}
                   ?>
    	</table>
    

    Thanks!

  • Was just about to ask the same question 🙂

    I managed to do it using the following code:

    function my_acf_load_value( $value, $post_id, $field ) {
        $value = get_the_title(); 
        return $value;
    }
    add_filter('acf/load_value/name=FIELD_NAME', 'my_acf_load_value', 10, 3);
  • I can’t believe that this thread exists – this is exactly what I was working on and nearly gave up after a few hours of trying to figure it out. So, I have a really stupid basic question on this front, now that I’ve got my race calendar working (seriously, was actually working on a race calendar too):

    When working with an UL / LI structure it injects the month name into the proper sorted location – is this possible with a table structure? I can’t get the month names to insert themselves, they end up creating their own TR elements outside of the sorted elements.

    Thanks for this! Fabulous

  • I have fixed the bug. It had nothing to do with the ACF field plugin.
    Thanks for the quick replay though.

  • This issue will not happen if your filter correctly modifies the $post_id.

    So if i change the post_id to abcnew the filter will now correctly modifie the post_id ? As i posted before i have paid for the help because i don’t have any knowlage in php

  • I’m actually creating brand new ACF fields, and not trying to use any old data.

    I’ll look into the update field documentation. I would have done a DB import, at a mySQL level, but the data was superflous and I only needed certain portions of the site.

  • Hi Elliot,

    Thanks a lot for following this issue I was having, and many other you helped me to address 🙂

    I ended solving this with a gravity forms hook (to stick to gf). The hook is very simple and I’m posting just in case someone else might find it helpful.

    add_action("gform_after_submission_5", "acf_post_submission", 10, 2);
    function acf_post_submission ($entry, $form)
    {
       $field_key = 'field_52fae7b9b229c';
       $post_id = $entry["post_id"];
       $value = get_field($field_key, $post_id);
       $value[] = array('app_id' => $entry[3],'app_cover' => $entry[2]);
       update_field($field_key, $value, $post_id);
    }

    The only issue I’m trying to solve now is to write a script to don’t let the same user ID submit this form if it already submitted. I’m using the same form (ID->5) for all job posts, so I have to set no duplication for that post id only and allow if it’s a different id, but that’s more a question for gravity forms guys.

    Anyways if you have any idea, I will appreciate that you share it with me.

    Thanks for all.

  • Hi @[email protected]

    Changing these ID’s is 1 way to solve the issue, however please read my last reply as it also answers this question.

    Thanks
    E

Viewing 25 results - 18,676 through 18,700 (of 21,345 total)