Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Hi @squarestarmedia

    The key for a field cannot change. If it does, the reference value will not connect the value to the field.

    Think of the field’s key as a tables ID column.

    Unfortunately, this cant be generated and you will need to somehow save the key to the field and reuse the same kjey on each page load.

    If you are trying to create a field without defining a key for it, this will prove very difficult.

    Hope that helps.

    Thanks
    E

  • Hi @Richard

    Thanks for the feature request. I’ll have a think about how I can do the drag / drop soon.

    As for the issue with missing buttons on the flexible content field. This is a CSS bug which is present in the current repeater field.

    You an re-download the repeater field to fix this issue or wait for the official release this week.

    Thanks
    E

  • Hi @physalis

    This can be accomplished quite simply by using a counter variable which you can use to link the top elements, to the bottom elements like so:

    
    <?php if( have_rows('repeater_field') ): $i = 0; ?>
    	<div class="repeater_loop1">
    	<?php while( have_rows('repeater_field') ): the_row(); $i++; ?>
    		<div class="subfield">
    			<h2>repeater <?php echo $i; ?></h2>
    			<h3><?php the_sub_field('subfield1');?></h3>
    			<p><?php the_sub_field('subfield2'); ?></p>
    			<a href="#block-<?php echo $i; ?>">Continue reading</a>
    		</div>
    	<?php endwhile; ?>
    	</div>
    <?php endif; ?>
    
    <?php if( have_rows('repeater_field') ): $i = 0; ?>
    	<div class="repeater_loop2">
    	<?php while( have_rows('repeater_field') ): the_row(); $i++; ?>
    		<div class="content-bluck" id="block-<?php echo $i; ?>">
    			<h2>#div (repeater <?php echo $i; ?>)</h2>
    			<h3><?php the_sub_field('subfield3');?></h3>
    			<p><?php the_sub_field('subfield4'); ?></p>
    		</div>
    	<?php endwhile; ?>
    	</div>
    <?php endif; ?>
    

    You will need to use 2 loops and I have taken the liberty of upgrading your code to use the have_rows function which is available in v4.3.0 as ‘the_repeater_field’ is quite old now

    Thanks
    E

  • Hi @zulfiqar.a.memon

    FYI: You can debug PHP code like so without needing to use JS:

    
    <?php 
    
    echo '<pre>';
    	print_r( get_field('cm_page_id') );
    echo '</pre>';
    die;
    
     ?>
    

    What does the PHP print_r give you? Perhaps the returned value is an array or object?

    Thanks
    E

  • Hi @rammelasen

    The $post_id parameter you are talking about tis an option to target a post to load data from.

    FYI: the the_sub_field function does NOT contain a $post_id parameter. This is incorrect

    If adding this 73 as the $post_id to the has_sub_field function, then this confirms that ACF is not able to find the correct $post_id on its own.

    Perhaps the issue is caused by another plugin or code (which contains a WP_Query loop / setup_postdata function) that is modifying the global $post object.

    Before your ACF code, can you dump out the global post id like so:

    
    <?php 
    
    global $post;
    
    echo '<pre>';
    	var_dump($post->ID);
    echo '</pre>';
    die;
    
     ?>
    

    What value to you get? Is this the correct ID for the page?

    Thanks
    E

  • Hi @GavinA1970

    The simpleset way is to break the while loop after you render the image like so:

    
    <?php while( has_sub_field('project_images') ): ?>
    	<?php $firstimage = wp_get_attachment_image_src(get_sub_field('project_image'), 'full'); ?>
    	<img src="<?php echo $firstimage[0]; ?>" alt="" style="display: none;" class="fp_preview" />
    	<?php break; ?>
    <?php endwhile; ?>
    

    That will break out of the nested loop and continue the previous loop.

    Hope that helps.

    Thanks
    E

  • Hi @Agrajag

    Calling a custom field looks like so:

    
    $rating = get_field('rating', 123);
    

    Where 123 is the post_id you want to load the value from.

    Does that help?

    Thanks
    E

  • Hi @phillustration

    You can introduce a simple counter variable like so:

    
    <?php  
    /*
    *  PROFILE BLOCK
    */
    $i = 0;
    
    while(has_sub_field("secondary_departments")): $i++; ?>
        
        <?php if(get_row_layout() == "secondary_department"): // layout: Content ?> 
        	<h3><?php the_sub_field('department_header'); ?></h3>
            <?php the_sub_field('department_description'); ?>
    
            <img src="<?php the_sub_field('department_thumbnail'); ?>" />
    	<?php endif; ?>
    	
    	<?php if( $i == 4 ): $i = 0; ?>
    		<div class="clear"></div>
    	<?php endif; ?>
     
    <?php endwhile; ?>
    

    Thanks
    E

  • Hi @pboisclair

    Would you mind posting some log in details for the site in question? You can mark the reply as private.

    I’ll login and take a look myself

    Thanks
    E

  • Hi guys

    Thanks for the request. i will definitely consider creating one after v5 is launched!

    Perhaps in the meantime, you could post up some example xml files to get an idea of how the data would look?

    Thanks
    E

  • Hi @Baybtout

    The ‘Loop File’ is not a file as such, but is a block of code which is used in any template to display 1 or more post object.
    You can learn more about ‘the loop’ on the WordPress website.

    Most likely, you want to find and edit the single.php or page.php file fo a single post. And the index.php or archive.php file for multiple posts pages.

    That’s all I can help you with as this is support for ACF related questions, not basic core WP questions.

    Thanks
    E

  • Hi Elliot,

    I have set 'html_after_fields' => '<input type="hidden" name="post_type" value="products">' in the form to the options array. In the functions.php, I have $post_type = $_POST['post_type']; to reuse the same form for posting different post types.

    But this is breaking and after submission, it redirects to 404. I think this is because the hidden field is nested inside <div id="poststuff">.

    Is there any way I can move it outside the poststuff div?

    I tried looking at the source in api.php but did not find any way to directly set the post type into the $options array. I think it would be great to have an option to set post_type in the options array and if it is not set, then default it to “post”.

    Thanks.

  • Hi Elliot,

    Thanks for the reply. I found it helpful and I am creating a series of classes now to build fields and field groups.

    I have run into an issue though:

    I have a base acfField class from which I extend the different types. I was using the uniqid() function in the constructor to generate the key IDs as you suggested, but they weren’t ‘sticking’. Every time I refresh the page, the key for any new acfField() object regenerates. This actually prevents the field from getting written to the database when saving a post with the field(s).

    Any suggestions on how to get around this? In reality I only need it in situations where 2 fields exist with the same key (the key is based on the name at the moment). So far my solution has been to manually add a incremented number to the key for situations where there is a clash, but tracking that manually could become really unwieldy, depending on the complexity of the setup. It also seems risky, in that problems could arise that are not immediately obvious.

  • For reference, I threw together a test page with a nested repeater with an unmodified version 1.1.0. Here are the results…

    1024px
    1024 Browser Width

    1280px
    1280 Browser Width

    1440px
    1440 Browser Width

    Anything wider and it’s not an issue, but I can’t reasonable expect all clients to have anything larger than 1280.

  • Thank you, I have used the following to get the required results:

     <?php if(get_field('currentShows', $post->post_parent)) { ?>
    			       
    <?php while(has_sub_field('currentShows', $post->post_parent)): ?>
    				 
     <li><a href="<?php the_sub_field('currentLink'); ?>"><?php the_sub_field('currentLinkText'); ?></a></li>
    				   
    <?php endwhile; ?>
    	<?php }
    				
    	else {
    	echo 'Coming soon';
    	} ?>

    Thanks

  • this way i get the title of the parent page, maybe the code helps you:

    <?php if(is_page()):
        $toppage=array_reverse(get_post_ancestors($post->ID));
        if($toppage[1]){
            echo '<h1 class="site-title">'.get_the_title($toppage[1]).'</h1>';
        }
        endif;
    ?>
  • I have tried the above but I am not having much success.

    I am using a repeater field but want the same results (display parent values on a sub page).

    The code I am using on the parent page is:

    <?php
        $rows = get_field('currentShows');
         if($rows)
          { 
           foreach($rows as $row)
    	{ ?>
    	 <li>
               <a href="<?php echo $row['currentLink']; ?>">
                 <?php echo $row['currentLinkText']; ?>
               </a>
             </li>
    	<?php
    	    } //end for
    	     }// endif 
    	else {
    	      echo 'Coming soon';
    	     }
    	     ?>

    Any help much appreciated.

    Thanks

  • Hi,

    I had this same problem (can’t add filles, dont show visual editr), but in my case solution was easy.

    Please check your footer code:
    <? wp_footer(); ?>

    or if you use custom template
    <?php get_footer(); ?>

    I use the same version of WordPress and ACF
    Meyby this is solution for this problem.

    If you need, my all code:`/* Template Name: Dodawanie zlecenia */ ?>
    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
    <html xmlns=”http://www.w3.org/1999/xhtml”&gt;
    <head>
    <?php acf_form_head(); wp_head(); ?>
    <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
    <title>Nowe zamówienie – Drukarnia DPI</title>
    <META NAME=”ROBOTS” CONTENT=”NOINDEX, NOFOLLOW”>
    <link href=”<?php bloginfo('stylesheet_directory'); ?>/css/logowanie.css” rel=”stylesheet” type=”text/css” />
    <link href='http://fonts.googleapis.com/css?family=Lato:300,400,700,400italic&#039; rel='stylesheet' type='text/css'>
    <?php
    $args = array(
    'post_id' => 'new',
    'field_groups' => array( 204 ),
    'submit_value' => 'Realizuj'
    );
    ?>
    </head>
    <body>
    <?php acf_form( $args ); wp_footer(); ?>
    </body>
    </html>`

    Sorry for my english.
    If i’m just stupid and only I forget about footer sorry for hopes.
    In my country now is middle of night

  • hello!

    Just incase anyone else was interested, I thought I would share where I got to.

    The problem wasn’t with the query_posts as such, although I can still only get it to work with the switch to blog low down just before the query.

    The problem was that the function wasn’t getting called in the first place. I had thought that changing the add_actions at the top of the file so that any wp ajax action going to the acf query post went to my query post function, it would work.

    What I have actually ended up doing is writing some js in my plugin which watches the wp ajax call and if it is from one of my fields, it redirects it to my query post function.

    I can’t imagine anyone would want to replicate this but if someone does I would be happy to share. I haven’t quite worked out how to pull the list of post types in yet though.

    I think it is great you answer these questions in the first place and I am a big fan of ACF and all the things yo’ve managed to do with it!

  • Just to clarify for anyone who comes across this later:

    My pre_get_posts action was setting query parameters not just for the main query (as I intended) but also the query by the Gallery plugin that gets the attachment data. These query parameters caused the get_posts query in gallery.php to return nothing.

  • What happens if you add $query->is_main_query() to your if statement?

    
    function allstar_buzzworthy_published_sort( $query ) {
            // If not the admin section
            if ( !is_admin() &&  $query->is_main_query()) {
                // If on a taxonomy page
                if ( is_tax() ) {
                    $query->set( 'meta_key', 'date_published' );
                    $query->set( 'orderby', 'meta_value' );
                    $query->set( 'order', 'DESC' );
                }
            }
        }
        add_action( 'pre_get_posts', 'allstar_buzzworthy_published_sort' );
    
  • I did some debugging in gallery.php and found that the issue his happening in the format_value function. The $value variable has the IDs of the attachments as it should, but when the get_posts query is run to get the data from those attachments, nothing is returned. I’m thinking my theory about the $query->set calls messing with the get_posts query. I’m going to see if I can tweak it and make it work.

  • The issue for me was specific to $query->set('s', ' ');. I added it to fix empty search queries returning a 404 page.

    I set a bunch of other query vars in the same function but going through one by one, this was the only one to cause error.

    Btw, you’re missing a single quote before date_published.

      
    function property_filters($query) {
    
      // ...
    
      /**
       * Fixes issue with blank search queries returning 404
       */
      if (!is_admin() && isset($query->query_vars['s']) && empty($query->query_vars['s'])) {
        $query->set('s', ' ');
      }
    }
    add_action('pre_get_posts', 'property_filters');
    
  • I’m digging into the gallery.php code a little bit and I have a thought as to what the problem is. Let me know if this makes any sense.

    This is the code to get the attachments form the database:

    // find attachments (DISTINCT POSTS)
    $attachments = get_posts(array(
        'post_type' => 'attachment',
        'numberposts' => -1,
        'post_status' => null,
        'post__in' => $value,
    ));

    Is it possible that my $query->set( 'meta_key', 'date_published' ); is affecting this query also, since it’s using get_posts instead of making a brand new WP_Query? So in my case, it’s trying to order the attachments by date_published and since that doesn’t exist, it’s not returning anything? Will investigate further.

  • Hi @elliot,
    It turns out that its another plugin that is putting jquery migrate in there. This is turning out to be a bit more complicated than I anticipated.
    I think I am just going to focus my energy on cacheing.

    To answer your question the add-ons are fairly recent. I think I bought them in October. Probably not old enough to warrant jquery migrate. I have included them in the theme so I’m a bit hesitant to update them even though I noticed there is an update available.

    Thanks so much for your help.

Viewing 25 results - 19,826 through 19,850 (of 21,394 total)