Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Hi @Pyromania666

    Thanks for the code, which looks fine to me.
    The only issue I see is:

    
    echo "<h3>".$images['id']."</h3>";
    

    $images is an array and does not contain an ‘id’. Perhaps this is causing a PHP error? But even that would not change the results shown…

    If you remove the flexslider classes and just output the images, Is the MARKUP correct?

    Perhaps the issue is not with the PHP, but with some JS which is replacing the Markup?

    Thanks
    E

  • Hi @digitalfaber

    There are 2 issue with your code that I can see:
    1. You are using the_sub_field, when you should be using get_sub_field
    2. Your $args are OUTSIDE the has_sub_field loop so your WP_Query or get_posts call will only happen once, not for each row in the repeater field

    Thanks
    E

  • Hi @Fulvio

    Thanks for the question. The ACF framework is not built to save multiple values to the DB for each field, only one.

    The repeater field can handle multiple values because it adds an extra level of logic. This is why it is a premium add-on.

    I would advise that you think about using a custom DB table to save all the data to. That way, you have full controll over the SQL.

    Your field file has a function called update_value. This is where you can do custom SQL.

    Also, the load_value function will allow you to read in the data through custom SQL.

    Hope that helps.

    Thanks
    E

  • Yes your assumption is correct. Sorry if i am not explaining this well.
    Here is my code:

    
    <!-- Main Content -->
        <div class="large-12 columns" role="content" style="margin-top: 2em;">
    		
    	<?php while ($portfolio->have_posts()) : $portfolio->the_post(); ?>	
    		<?php $pagename = get_query_var('name'); ?>
    		<div class="large-4 columns panel">
    			<h3><?php the_field('title'); ?></h3>
    			<?php the_field('description'); ?>
    			<a href="#" data-reveal-id="myModal"><?php the_post_thumbnail(); ?></a>
    		</div>
    		
    		<div id="myModal" class="reveal-modal">
    			<?php $images = get_field('image_gallery');
    				
    				if ( $images ):
    				echo "<h3>".$images['id']."</h3>";
    			?>
    			
    		
    			
    			<div class="flexslider">
    				<ul class="slides">
    					<?php foreach( $images as $image ): ?>
    					<li><img src="<?php echo $image['url']; ?>" /></li>
    					<?php endforeach; ?>
    				</ul>
    			</div>
    			<?php endif; ?>
    		</div>
    		
    	<?php endwhile; ?>
        </div>
        
        <!-- End Main Content -->
    

    Basically I setup a while to check for the custom post type “portfolio” which in turn each post uses the ACF gallery field. I loop through and if there are posts, it posts them on the page. But for the gallery it seems to only do the last gallery of the most recent post, and it shows the same gallery for all the posts.

  • Hi @Ron Willemse

    The get_terms function will return an array of terms. This means you need to loop through the code and run your if statement for each term like so:

    
    <?php 
    
    $terms = get_terms("shops");
    
    if( $terms )
    {
    	foreach( $terms as $term )
    	{
    		$value = get_field('shop_options', 'shops_'.$term->term_id);
    		if( $value == "option_1" )
    		{
    		 echo 'something';
    		}
    	}
    }
    
     ?>
    

    Hope that helps

    Thanks
    E

  • Hi @bobz

    I think the issue is that because on page load, the select field does not contain any value because it has no option element to select.

    This means, your JS can’t find the origional value to select when you update the DOM with new option elements.

    Perhaps in your PHP AJA function, you can lookup the value for the field, and include this ‘selected’ data for the option you want selected.

    To do this, you will need to change the way you post pack your data as a comma separated string wont allow for this kind of data.

    Try using JSON to return an array of items, plus the selected value if it has one!

    Does that help?

  • Hi Elliot,

    thanks for your prompt reply!

    I retraced my steps on a clean (local) install; same problem.
    I retraced my steps on a test wordpress site, and things worked as I wanted.
    I then tried to retrace all the steps I took to create a form on my live site (in maintenance mode, it’s a bit of a mess) but now I get the following error when I submit a form from the front end:

    Warning: Cannot modify header information – headers already sent by (output started at /THEMENAME/page-full-width.php:8) in wp-includes/pluggable.php on line 899

    page-full-width.php is the template where I call the acf_form_head, and the form. So basically just:

    <?php 
    acf_form_head();
    get_header();
    ?>

    and after some html markup

    <?php 
    $options = array( 							'post_id' => 'new', 							'field_groups' => array( 31 ),  
    ); 
    if (is_user_logged_in()) { 
    acf_form( $options ); 
    }
    ?>

    I don’t think the above code is incorrect?

    In the functions.php I have the following:

    function my_pre_save_post( $post_id )
    {
        // check if this is to be a new post
        if( $post_id != 'new' )
        {
            return $post_id;
        } 
    
        // Create a new post
        $post = array(
            'post_status'  => 'draft' ,
            'post_title'  => $_POST["fields"]['field_528a8d1ae2674'],
            'post_type'  => 'custom_type',
            'post_content' => $_POST["fields"]['field_528a8d1fe2675']  
        );  
     
        // insert the post
        $post_id = wp_insert_post( $post ); 
     
        // update $_POST['return']
        $_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );    
     
        // return the new ID
        return $post_id;
    }
     
    add_filter('acf/pre_save_post' , 'my_pre_save_post' );
     
    add_action( 'wp_print_styles', 'my_deregister_styles', 100 ); 
    function my_deregister_styles() {
        wp_deregister_style( 'wp-admin' );
    }

    The only fields I have set up in ACF to be used in the front-end form are title, content, and a map.

    Hope this helps! I will keep on tryin’ 😉

  • Hi @martinrp

    Let me know what you find. I’m quite interested to see how the domain mapping plugin can integrate with WP images.

    Thanks
    E

  • Hi @Pyromania666

    Can you please post a snippet of your code which is used to make the gallery?
    Am I right in assuming this piece of code is within a loop which is rendering many posts on 1 page?

    There should be no need for a ‘unique ID’ for each gallery, the get_field function can load from multiple posts on 1 page. Perhaps the $post object is not correctly setup in your loop?

    Thanks
    E

  • Hi @beliy333

    Thanks for clarifying.
    What you need to do is render out ALL of the required PHP into the Carousel. Most Carousel JS plugins allow for not only an image, but for HTML as well.

    You will need to research the Carousel documentation to find out how this is possible, but once understood, you can simply modify your code to also render out the other sub fields in the correct markup.

    Does that help?

    Thanks
    E

  • Hi elliot,
    I saw in the code you’re working on the wpml issue, any help needed ? any idea when you’ll be able to make it ?
    thank you

    nb : i’m still enable to get the fields in the translated categories, of course a quick workaround is to not specify the category…so it will show up everywhere..;but that is not really a cool solution, any other workaround for now ?

  • That should only give you 1 post?

    You can also do this:

    
    
    $args = array(
    	'numberposts' => 5,
    	'meta_key' => 'hp_slider',
    	'meta_compare' => '=',
    	'meta_value' => "1"
    );
    
    
  • This is how I got it working, if this is a terrible solution, please, let me know 🙂

    <?php 
    			 
    // args
    $args = array(
    	'numberposts' => 1,
    	'meta_key' => 'hp_slider',
    	'meta_type' => 'BINARY',
    	'meta_value' => "1"
    );
    			 
    // get results
    $the_query = new WP_Query( $args );
    		 
    // The Loop
    ?>
    <?php if( $the_query->have_posts() ): ?>
    
    	<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
        HTML CODE
    	<?php endwhile; ?>
    <?php endif; ?>
  • Here is my HTML markup:

    <form id="post" class="acf-form" action="" method="post" >
                   <div style="display:none">
                      <script type="text/javascript">
                         acf.o.post_id = "new";
                      </script>
                      <input type="hidden" name="acf_nonce" value="4ceed66667" />
                      <input type="hidden" name="post_id" value="new" />
                      <input type="hidden" name="return" value="http://localhost:8888/product/submit-product?updated=true" />
                      <div id="wp-acf_settings-wrap" class="wp-core-ui wp-editor-wrap tmce-active">
                         <div id="wp-acf_settings-editor-tools" class="wp-editor-tools hide-if-no-js">
                            <a id="acf_settings-html" class="wp-switch-editor switch-html" onclick="switchEditors.switchto(this);">Text</a>
                            <a id="acf_settings-tmce" class="wp-switch-editor switch-tmce" onclick="switchEditors.switchto(this);">Visual</a>
                            <div id="wp-acf_settings-media-buttons" class="wp-media-buttons"><a href="#" id="insert-media-button" class="button insert-media add_media" data-editor="acf_settings" title="Add Media"><span class="wp-media-buttons-icon"></span> Add Media</a></div>
                         </div>
                         <div id="wp-acf_settings-editor-container" class="wp-editor-container"><textarea class="wp-editor-area" rows="20" cols="40" name="acf_settings" id="acf_settings"></textarea></div>
                      </div>
                   </div>
                   <div id="poststuff">
                      <div id="titlediv">
                         <div id="titlewrap"><label class="screen-reader-text" id="title-prompt-text" for="title">Enter title here</label><input type="text" name="post_title" size="30" id="title" placeholder="Enter product title here" autocomplete="off"></div>
                      </div>
                      <div id="wp-frontendform-wrap" class="wp-core-ui wp-editor-wrap html-active">......
                      </div>
                      <div id="acf_75" class="postbox acf_postbox default">......
                      </div>
                      <div><input type="hidden" name="post_type" value="products" /></div>
                      <!-- Submit -->
                      <div class="field">
                         <input type="submit" value="Submit" />
                      </div>
                      <!-- / Submit -->
                   </div>
                   <!-- <div id="poststuff"> -->
                </form>

    The html_after field is <div><input type="hidden" name="post_type" value="products" /></div>

    Thanks.

  • I have the same issue. I can save 2 lines conditional options but adding a 3rd conditional requirement fails and the new ruels are not saved.

  • Hi E,

    I have one more question pls, here is my js code: http://pastebin.com/hejnDsgg
    What I do here is:

    1. I have 3 different post types where I want to use this auto populate
    2. Every post type has different id for select menu, so I have put their id into variables to make life easier

    3. I get selected value from ‘Select Country’
    4. I do AJAX to get list of areas and cities for that country

    5. I get response as comma seperated (eg: city1,city2,city3)
    6. I do with jquery each:
    $( '#' + selector_area ).append( $('<option></option>').val(text).html(text) )

    This is how I append values as options under my select menu.

    Now everything here works fine, but problem is that saved value is not selected or displayed.
    Every time I refresh ‘Edit posts’ area is not correct so I need to select area every time I edit and save post.

    Any advice please?

    BR
    V

  • hello @elliot
    I place the code in content.php and it looks like this:

    <div class="entry-content">
    		<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentythirteen' ) ); ?>
    		<ul>
    			<li>Price in £: <?php the_field("price-in-£"); ?></li>
    			<li>Barcode: <?php the_field("barcode"); ?></li>
    			<li>Place: <?php the_field("place"); ?></li>
    		</lu>
    		<?php wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
    </div><!-- .entry-content -->

    Is there a problem with it?

  • Hi Elliot,

    There is no error in the source except

    <script type='text/javascript'>
    /* <![CDATA[ */
    var pluploadL10n = {"queue_limit_exceeded":"You have attempted to queue too many files.","file_exceeds_size_limit":"%s exceeds the maximum upload size for this site."........

    .

  • Hi @Elliot! Thanks for the quick reply. Double checked those fields but none of them are checked > <

    Screenshot: https://www.monosnap.com/image/RsbKTOCqUS2ISoJb9cxsZ79AU/#

  • Hi @rammelasen

    I’m not sure if the page_id argument will ignore the post_type argument (defaults to ‘post’).

    Perhaps this is documented in the WP WP_Query args documentation.

    Thanks
    E

  • Hi @elliot, of course.

    When we create an ACF fields group, it is stored as a wp_posts record in the database and the post_name db field (which is the id of the group) is an generated string from the group title, e.g:
    – The group title (post_title db field) is Options : Général
    – The generated id (post_name db field) will be acf_options-g%c3%a9n%c3%a9ral

    The equivalent php export result will be:

    register_field_group(array (
    ‘id’ => ‘acf_options-g%c3%a9n%c3%a9ral’,
    ‘title’ => ‘Options : Général’,
    ‘fields’ => array ( …

    It would be better for us, french fan of ACF, to have a non-accented generated group id 😉 That id would be acf_options-general

  • So basically what I do now is wrap the code into this instead:

    <?php $pistkarta = new WP_Query( array( 'page_id' => 73, 'showposts' => -1 ));
    							while ( $pistkarta->have_posts() ) : $pistkarta->the_post(); ?>
    
    /* Content here from page with ID 73 */
    
    <?php endwhile; ?> 
    

    Jeppe

  • Hi @Elliot, sure thing!

    Here’s the screenshot 🙂 https://www.monosnap.com/image/4DJcQI5pTPBqJlzoLsT2Q7IHg/#

  • Hi Elliot,

    This is weird. If I set the 'html_after_fields' => '<input type="hidden" name="post_type" value="products"> then it does not invoke the filter acf/pre_save_post. When it is set to empty, it calls the filter properly. Do you have any insights?

    Thanks.

  • I did a var dump of $_POST like so:

    $post_type = $_POST['post_type'];
        echo 'post type: ' . $post_type . '<br/>';
        echo "<pre>";
        var_dump($_POST);
        echo "</pre>";
    
        exit();

    but it seems it never reaches here and throws a 404. The only thing that causes this problem is the hidden field. I have the plugin Debug Objects but am not sure how to catch the error here. A little advice would definitely help me debug and tell you the output.

Viewing 25 results - 19,801 through 19,825 (of 21,394 total)