Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Hi,

    I’m not sure how you went with this, but I am trying to add some ACF fields to the Single Products Page in Woocommerce. I was hoping to use the hooks that woocommerce provides to add the custom fields stuff, but I can’t seem to get the fields to output anything.

    in my functions.php I have added an action like so:

    // Add ACF Info to Product display page
    add_action( 'woocommerce_after_single_product_summary', "ACF_product_content", 10 );
    
    function ACF_product_content(){
      
      echo '<h2> ACF Content </h2>';
      
      if (function_exists('the_field')){
        echo '<p>Woohoo, the_field function exists! </p>';
    
        the_field('test_field');
    
      }
      
    }
    

    The h2 and the p are displayed, but the field itself doesn’t get rendered. Any thoughts?

    Cheers.

  • Still searching to do this with the gallery field add on… cannot make something work. Will be easier I guess with a repeater field.
    The difficulty I think is how to get the attachement id for each image as the gallery field call for all pictures $attachment_id = get_field('gallery');' not working. So I tried this:

    <?php
    /*
    *  Gallery
    */
    // url = $image[0];
    
    $images = get_field('gallery');
    $field = get_field_object('size-gallery');
    $value = get_field('size-gallery');
    $label = $field['choices'][ $value ];
     
    if( $images ): ?>
                    <?php foreach( $images as $image ): ?>
    				<?php $image2 = wp_get_attachment_image_src( $image['id'], $label ); ?>
    <li>
    			<a href="<?php echo $image2[0]; ?>" class="fancybox" rel="gallery" title=""><div class="miniature"><img src="<?php echo $image2[0]; ?>" /></div></a>
    		</li>
            
    	            <?php endforeach; ?>
    <?php endif; ?><!--FIN DE GALERIE PHOTOS -->

    The gallery works but the $label has no effect.

    Any idea would be great. I really need to make it works. Thanks

  • Hi @Xav

    including files or ‘partials’ is a common templating task which does not usually prove so dificult. There must be something else going on here.

    The require($_SERVER['DOCUMENT_ROOT'].'/pwp/wp-load.php'); code should never be included in a correct page template.

    I think the issue is that you are including them in a non PHP friendly way. How does Zurb’s data interchange work?

    Your origional code:

    <div data-interchange="[<?php echo get_stylesheet_directory_uri();?>/library/interchange/contact_details_small.php, (small)], [<?php echo get_stylesheet_directory_uri();?>/library/interchange/contact_details_default.php, (medium)], [<?php echo get_stylesheet_directory_uri();?>/library/interchange/contact_details_default.php, (large)]">
    </div>

    Shows that you place urls into a data attribute on a div. Have you checked the docs to see if these can be PHP files? If so, are they loaded via an ajax request? If so, how would WP know what $post to query for that file?

    Thanks
    E

  • Hi @ramesh

    This FAQ will help explain what is happening:
    http://www.advancedcustomfields.com/resources/faq/losing-data-save/

    Thanks
    E

  • 1. Repeater field with a text sub-field type and a true_false sub-field.

    2. this is a sub-field

    3. the content entered in the text field.

    4. Page B is a wordpress page which wont have any user content loaded from the standard wordpress CMS or any fields shown from ACS. The data from 1 row of the repeater on page A will auto populate on page B if the true_false checkbox is checked in that row.

    5. Page A is accessed from a link on the website. Page B will be accessed from a link on page A.

    6. The content in the subfields in the repeater will either post to page A or B depending on if the checkbox is checked. But all of the rows will always be managed from a “wordpress page” in the wordpress admin. I am using a rule to show if field group is equal to page A.

    Hopefully this clarified everything.

  • Ok so I went through that tutorial – bedrooms was already one of the fields I need to sort by, so I thought it would be easy – however, I am having a lot of trouble with this still.

    This is the code I put in my functions file:

    add_action('pre_get_posts', 'my_pre_get_posts');
     
    function my_pre_get_posts( $query ) {
    
        if( is_admin() ) { return; }
     
        $meta_query = $query->get('meta_query'); // get original meta query
        
        
        // validate type
        if( empty($_GET['bedrooms']) )
        {
    	    return;
        }
        
        
        // get types as an array
        // - use explode to get an array of values from type=a|b|c
        $bedrooms = explode('|', $_GET['bedrooms']);
        
        
        // set compare for the meta_query
        // - http://codex.wordpress.org/Class_Reference/WP_Query
        $meta_query['relation'] = 'OR';
        
        
        foreach( $bedrooms as $bedroom )
        {
    	    $meta_query[] = array(
                'key'       => 'bedrooms',
                'value'     => '"' . $bedroom . '"',
                'compare'   => 'LIKE',
            );
        }
    	
    	
        $query->set('meta_query', $meta_query); // update the meta query args
        
        return; // always return
    }
    

    This is the code I have on the page I want to have filtering:

    <div id="search-houses">
    <?php 
     
    	$field = get_field_object('bedrooms');
    	$values = explode(',', $_GET['bedrooms']);
     
    	?>
    	<ul>
    		<?php foreach( $field['choices'] as $choice_value => $choice_label ): ?>
    			<li>
    				<input type="checkbox" value="<?php echo $choice_value; ?>" <?php if( in_array($choice_value, $values) ): ?>checked="checked"<?php endif; ?> /> <?php echo $choice_label; ?></li>
    			</li>
    		<?php endforeach; ?>
    	</ul>
    </div>
    <script type="text/javascript">
    (function($) {
     
    	$('#search-houses').on('change', 'input[type="checkbox"]', function(){
     
    		// vars
    		var $ul = $(this).closest('ul'),
    			vals = [];
     
    		$ul.find('input:checked').each(function(){
     
    			vals.push( $(this).val() );
     
    		});
     
    		vals = vals.join(",");
     
    		window.location.replace('<?php echo home_url('find-my-apartment'); ?>?bedrooms=' + vals);
     
    		console.log( vals );
     
    	});
     
    })(jQuery);	
    </script>
    

    This is the page: http://tlc.mainteractivegroup.com/find-my-apartment/

    The first problem is that it is giving me a PHP error on this line:<?php foreach( $field['choices'] as $choice_value =>

    The second problem is, when I add ?bedrooms=3 or any other number to the URL it goes to a 404 page.

    The third thing I noticed – don’t know if this matters or not but when I add ?post_type=apartment to the URL it brings up the page just fine.

    So I really need some help getting this part at least functional. I also don’t really understand completely how this function interacts with the existing loop I have on the page. You can see below the PHP error I have a loop that displays out all the apartments with the custom fields. Do I need to do anything to change that loop for this to work?

    Thanks in advance!

  • Hi Elliott,

    Thanks for your suggestion, I did try that, and the value was appearing. But I actually got it working!

    The problem was the double quotes in the shortcode.

    [fancygallery id="1" album="6"]

    If I removed the double quotes, it worked.

    [fancygallery id=1 album=6]

    But I could not tell the client to always delete the double quotes when inserting a shortcode, so I kept the short code as-is:

    [fancygallery id="1" album="6"]

    and within advanced custom fields, I changed the format setting for the Text field type to “Convert HTML into tags” instead of “No formatting”

    It works now!

    Thanks,

    JC

  • Hi !
    I find this solution with query !
    This code work perfectly.

    ` $sidebar = get_field(‘sidebar-widget’);
    $args = array(
    ‘post_type’ => ‘sidebar-widget’,
    ‘page_id’ => $sidebar
    );
    $query = new WP_Query( $args );
    // The Loop
    ?>
    <?php if($query->have_posts()) : ?>
    <?php while($query->have_posts()) : ?>
    <?php $query->the_post(); ?>
    <?php include(‘widget/content-sidebar-widget.php’); ?>
    <?php endwhile; ?>
    <?php wp_reset_postdata(); ?>
    <?php endif; ?>`

  • Hello @elliot,
    thanks for your attention!

    the console ajax error responses are shown in the image below:

    https://www.dropbox.com/s/m3a9c8igkzh9j5p/Captura%20de%20tela%202014-02-12%2013.14.19.png

    in firefox, this is the markup shown in the elements console (the image url is correct, but look that there is a “qbfrdtrjcpyjcqxlodhz” class in the img element).

    https://www.dropbox.com/s/7v9jo4ptyvtu4bn/Captura%20de%20tela%202014-02-12%2013.22.27.png

    In this case, I have only two relationship itens.
    If I access the img url link, the image shows up.

    Additional infos: running in a local server (MAMP)

  • I tried a couple of things but neither worked. First I just removed the setup_postdata($post); from the code but in doing that the page looked the same.

    Next I tried the following code:

    <header>
    
    <!--logo/nav/social-->
    <div class="container">
    
    <!--logo-->
    	<a class="logo" href="<?php bloginfo('url'); ?>">
    		<img class="logo" src="<?php bloginfo('template_directory'); ?>/images/logo.png" alt="<?php bloginfo('name'); ?>" />
    	</a>
    	
            
     <?php include(TEMPLATEPATH . '/nav.php'); ?>
     
     <div class="social">
         <a class="facebook" href="#" target="_blank"><img src="<?php bloginfo('template_directory'); ?>/images/facebook.png" alt="<?php bloginfo('name'); ?>" /></a>
    	 <a class="twitter" href="#" target="_blank"><img src="<?php bloginfo('template_directory'); ?>/images/twitter.png" alt="<?php bloginfo('name'); ?>" /></a>
    	 <a class="youtube" href="#" target="_blank"><img src="<?php bloginfo('template_directory'); ?>/images/youtube.png" alt="<?php bloginfo('name'); ?>" /></a>
         <a class="linkedin" href="#" target="_blank"><img src="<?php bloginfo('template_directory'); ?>/images/linkedin.png" alt="<?php bloginfo('name'); ?>" /></a>
     </div><!--end.social-->
     
    <div class="clear"></div>
    
     <!--mobile header-->
     <div class="phone-nav visible-phone visible-tablet">
            <div class="mobile-phone visible-phone visible-tablet">
            
            <?php $posts = get_posts(array(
                	'post_type' => 'siteinfo',
                    'posts_per_page' => -1,
                    'orderby'=> 'ID',
                    'order' => 'ASC'
                  ));
    			  		
    	if ( $posts->have_posts() ) : while ( $posts->have_posts() ) : $posts->the_post();  
                         
    	$phone = get_field('phone_number'); ?>
    			
            <a class="phone-btn"  href="tel:1-<?php echo $phone; ?>"><img class="phone-icon" src="<?php bloginfo('template_directory'); ?>/images/white-phone.png" alt="menu" /><?php echo $phone; ?></a>
            </div>
            <div class="mobile-menu visible-phone visible-tablet"><a id="responsive-menu-button" href="#sidr-main"><img class="menu-icon" src="<?php bloginfo('template_directory'); ?>/images/menu-icon.png" alt="menu" />Main Menu</a></div>
     </div>
    
    </div><!--end.container-->
    <div class="mobile-back"></div>
    
    </header>
    
    <div class="phone-google">
    <div class="container">
    
    				<div class="phone">
    				    <p><img class="phone-img" src="<?php bloginfo('template_directory'); ?>/images/phone.png" alt="<?php bloginfo('name'); ?>" />
    	                
    	                <span><?php echo $phone; ?></span></p>
    	            </div><!--end.phone-->
                
       <?php endwhile; // end of the loop. 
    endif; ?>
                    
                    <div class="g-plusone" data-size="large"></div>
                                        
    <!-- Place this tag after the last +1 button tag. -->
    <script type="text/javascript">
    (function() {
       var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
       po.src = 'https://apis.google.com/js/plusone.js';
       var s = document.getElementsByTagName('script')[0];   s.parentNode.insertBefore(po, s);
    })();
    </script>
                                        
               
                    
    </div><!--end.container-->
    </div><!--end.phone-google-->

    But that made everything below the navigation disappear.

    Can you see anything else I may be doing wrong?

    Thanks!

  • Hi,

    I’m getting this on all edit pages and posts (even if no custom fields associated on those types)

    migrateWarnings
    ["jQuery.attrFn is deprecated", "jQuery.browser is deprecated"]
    	"jQuery.attrFn is deprecated"
    	"jQuery.browser is deprecated"

    On the post edit screens, I get acf-loading icons constantly spinning where acf fields would normally come in. It hangs forever and also disables all standard WP functionality eg, add featured image, switch between Visual or Text etc. Screen tab at top… nothing works/appears.

  • Hi Elliot,

    Thanks for getting back to me.

    The template is a custom include file. I have a custom template for my contact page and within that I’m calling the contact_details_small.php or contact_details_default.php that has the acf fields in. When the fields are placed directly in the contact template they work fine, but when I move them to the the include files I get nothing.

    I’m beginning to think maybe I’m just using the acf code wrong as the include files are definitely being read because plain html is being output. I simplified the code above so as to make it easier to understand. The full code in the include file is below:

    <?php
    require($_SERVER['DOCUMENT_ROOT'].'/pwp/wp-load.php');
    ?>
    
    <div class="phone_email_holder">
    
    <p>LARGE TEMPLATE</p>
    
    	<?php if( have_rows('phone_numbers') ): ?>
    			<?php while( have_rows('phone_numbers') ): the_row(); ?>
     			<div class="contact_field_wrapper row">
    	        	<div class="phone_email_label info_label"><?php echo get_sub_field('number_label') ?>:</div> 
    	        	<div class="phone_email_value"><?php echo get_sub_field('tel_number') ?></div>
    		    </div>
    		<?php endwhile; ?>
    	<?php endif; ?>
    	<?php if( have_rows('email_addresses') ): ?>
    			<?php while( have_rows('email_addresses') ): the_row(); ?>
     			<div class="contact_field_wrapper row">
    	        	<div class="phone_email_label info_label"><?php echo get_sub_field('email_label') ?>:</div> 
    	        	<div class="phone_email_value"><a class="" href="mailto:<?php echo get_sub_field('email_address'); ?>"><?php echo get_sub_field('email_address') ?></a></div>
    		    </div>
    		<?php endwhile; ?>
    	<?php endif; ?>
    </div>

    The “LARGE TEMPLATE” bit is being output from the above code. Just not the rest. All I’m doing is removing links from telephone numbers for the desktop version of the site and adding them back in for mobile versions.

    Thanks for looking into this.

  • Thanks for getting back to me. Looking at the console helped me find a solution.

    A couple of the field name had a question mark or forward slash in them. It seems these are illegal characters. The problem is my users will enter the field label which often contain a question mark. the field name is populated automatically but doesn’t strip out those illegal characters, leading to the JS error.

  • Hi Elliot,

    If you look at this site : http://www.sv-dhl.nl – you see that the Repeater field is working and the countdown clock isn,t.
    Repeater field above and below, the one with the pictures and the one with the logo.

    But if you look at : test.sv-dhl.nl you will see that the countdown clock is working but the repeater field isn’t. The picture one isn’t showing at all and the onne with the logo’s isn’t scrolling from right to left but stays still.

    The only different between the sites is that i remove the following line from the header.php :
    <script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js”></script&gt;
    The theme i’m using is Twenty Ten.

    Basicly i’m looking for a solution to get both the repeater field and the countdown working.

    Hope this will help you a bit more.

    Gr Joy

  • Hey @elliot! Thank you very much for taking your time to answer this 😉 I have a last question: ACF creates fields in DB with same name but with a “_” as prefix, are they necessary? May I run a query to delete fields starting with a _ ?

  • Hi @juanpablob

    The above is very similar to another question here:
    http://support.advancedcustomfields.com/forums/topic/relationship-between-flexible-content-post/

    The repeater and flexible content save data in the same way, so you will both end up with very similar code.

    Please read over the linked documentation articles to see how you can filter the WP_Query args and allow for sub field values int he meta_query.

    Thanks
    E

  • Hi @joecannes

    Your code looks good, but you don’t need the double quotes around the "$myvalue" variable.

    Perhaps the value is not being loaded. You can debug the data like so:

    
    $myvalue = get_field( "cf_custom_gallery" ); 
    
    echo '<pre>';
    	print_r( $myvalue );
    echo '</pre>';
    die;
    
  • Hi @bobz

    There is no limit in ACF, please read:
    http://www.advancedcustomfields.com/resources/faq/losing-data-save/

    Thanks
    E

  • Hi @Will

    The issue is that you are using the_row twice within the loop!

    Only use it once per loop like so:

    
    <?php
    if( have_rows('resources') ):
     
    	while ( have_rows('resources') ) : $row = the_row();
    
    		$type = $row['resource_type'];
    		echo "<h3>Type: " .  $type . " </h3>";
    	
    	endwhile;
    endif;				
    ?>
    

    Thanks
    E

  • Hi @gauden

    It is possible to query all the posts that have selected ‘Quest A’ within the flexible content field.

    You will need to read over the following tutorials:
    http://www.advancedcustomfields.com/resources/how-to/how-to-query-posts-filtered-by-custom-field-values/#example-5
    http://www.advancedcustomfields.com/resources/tutorials/querying-relationship-fields/

    Thanks
    E

  • Hi @chrisg

    $post_id = $pid; should be $post_id = "user_{$pid}";

    Please also debug your code before using the update_field function to make sure all the data is correct.

    it is most likely that $pid is not what you think it is.

    Thanks
    E

  • Hi @ramesh

    There is no limit from either WP or ACF.
    Does this answer your question?

    Thanks
    E

  • Hi @sja

    jQuery is a JS library that allows you to place event listeners on elements. One of these events is called ‘blur’. This is for when you blur out of an input field.

    There is no need to add an onblur attribute to the element, this is ‘old school’. Instead, use jQuery to attach an event listener to the element.

    Please refer to Google for any more help with the blur event.

    Thanks
    E

  • Managed to solve this like this:

    <?php 
    
    $distributor = get_field('distributors'); ?>
    
    <select>
    	<option value=""></option>
    	<?php foreach ($distributor as $key => $value) {
    		echo "<option name='' id=''>" . $distributor[$key] . "</option>";
    	} ?>
    </select>
  • Hi @dadra

    This can be achieved no different to that of a regular field:
    http://www.advancedcustomfields.com/resources/field-types/image/

    You can echo a size like so:
    echo '<img src="' . $image['sizes']['thumbnail'] . '" alt="' . $image['alt'] . '" />';

Viewing 25 results - 18,751 through 18,775 (of 21,345 total)