Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Hi Elliot,

    An old client has reached out to me after foolishly upgrading not only their WordPress install to the latest version (4.1), but also the previous version of ACF (3.?) to 4.4.0. without any regard to compatibility in general. Obviously some things have broken, and I’m trying to determine the quickest way to restore things to a working version. Of course there are no site backups, and from what I can tell, it appears that the previous custom fields I created are missing (not displaying), BUT the field groups themselves ARE still in tact. I’ve read in the forums about database upgrades during the plugin upgrade process and was wondering if that was something I could force to occur as a possible quick solution? As I’m exploring options, I was also wondering if you could provide me with information to download previous versions (3.x etc) to try resolving that way. For whatever reason, I’m unable to find those links on your site.

    Many many thanks in advance!
    -Eric

  • Actually, I managed to solve this problem in another way. I post here the solution in case somebody else is interested in the answer:

    1) I created a Wysiwyg Editor field.
    2) Added the field normally in my php file.
    3) In the post editor, I used the normal wordpress “more” tag, which automatically inserts the shortcode <!–more–> inside my content and creates two paragraphs automatically, one before and one after the shortcode.
    4) In my Jquery file, I wrote this code:

           $('p').html(function(_, text) {
            return text.replace('<!--more-->', '<a href="#" class="read_more">read more</a>' );
          });

    That’s it, basically. With that link and that class I can manipulate the link as I want.

  • Yeah now its clear 🙂

    Open your functions.php file and add this code if options page is not visible in WP menu

    // register options page
    if(function_exists('acf_add_options_page')) { 
    	acf_add_options_page();
    }

    When create field group with field f.e.’portfolio_background’
    When choose field group location -> Show this field group if [OPTIONS PAGE] is equal to [OPTIONS].

    Inside archive-projects.php add

    <?php the_field('portfolio_background', 'options');?>

    That would be the way how to echo some field and control it if you don’t have page in WP menu.

  • sorry. without basic php knowledge ACF is useless for you. (imho)
    because every frontend view need to be created at your own. (coded php/mysql/js/wp)

    if someone code that for you. content could be filled easy with ACF.
    but if you have to do it on your own, i assume it would be easier to search something else than ACF that no coding need. (visual composer: could maybe the tool that you search)

  • I think I’ve got it!

    
    <?php 
    	
    $images = get_field('header_image', 'option');
    $rand = array_rand($images, 1);
    	
    if( $images ): ?>
    	<div>
    		<img src="<?php echo $images[$rand]['url']; ?>" alt="<?php echo $images[$rand]['alt']; ?>" />
    	</div>
    <?php endif; ?>
    
  • I have the same issue, however, I was able to figure out how to get the url to work by modifying the meta_query in functions.php:

    
    $meta_query[] = array( 
    	    		relation => 'AND',
    	    		array(
    	                'key'		=> 'community',
    	                'value'		=> $community,
    	                'compare'	=> 'IN',
                    ),
                    array(
    	                'key'		=> 'listing_status',
    	                'value'		=> $status,
    	                'compare'	=> 'IN',
                    ),
                );
    

    So, when I visit http://www.website.com/listings/?listing_status=sold&community=cityname, if I have a Listing that is both sold and in cityname, the listing is displayed and my checkboxes show in the sidebar. However, as soon as my URL changes to something like http://www.website.com/listings/?listing_status=sold&community=newcityname (where “newcityname” is not marked as “sold”) I get the following error when where the checkboxes normally show:

    Warning: Invalid argument supplied for foreach() in /serverpath/wp-content/themes/themename/archive-listings.php on line 27
    (where line 27 is my foreach loop)

    Here’s my code:

    
    <?php 
    				$field = get_field_object('community');
    				$values = isset($_GET['community']) ? explode(',', $_GET['community']) : array();
    				
    				$field2 = get_field_object('listing_status');
    				$values2 = isset($_GET['listing_status']) ? explode(',', $_GET['listing_status']) : array();
    				?>
    				<ul class="communities">
    					<?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>
    				<ul class="status">
    					<?php foreach( $field2['choices'] as $choice_value2 => $choice_label2 ): ?>
    						<li>
    							<input type="checkbox" value="<?php echo $choice_value2; ?>" <?php if( in_array($choice_value2, $values2) ): ?>checked="checked"<?php endif; ?> /> <?php echo $choice_label2; ?></li>
    						</li>
    					<?php endforeach; ?>
    				</ul>
    

    How can I fix this?

    Also, how can I do the URL replacement when someone clicks on the checkboxes? I have the below setup which works for one custom field parameter at a time but not both:

    
    <script type="text/javascript">
        //Listing URL Query Change
    	(function($) {
    		$('.communities').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('listings'); ?>?community=' + vals);
    		});
    		$('.status').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('listings'); ?>?listing-status=' + vals);
    		});
    	})(jQuery);	
    </script>
    

    Thanks in advance for any help 🙂

  • You can do it like this without overwriting the core code:

    add_filter( 'acf/get_valid_field', 'change_input_labels');
    function change_input_labels($field) {
    		
    	if($field['name'] == '_post_title') {
    		$field['label'] = 'Custom Title';
    	}
    		
    	if($field['name'] == '_post_content') {
    		$field['label'] = 'Custom Content Title';
    	}
    		
    	return $field;
    		
    }

    This code goes into your functions.php file for example.
    Since i think not too many people needs this function, i don’t think we need a GUI for this, so we can mark this feature request as solved.

  • Hey Elliot,
    strangely this is not working for me.
    I’m using the WYSIWYG editor within the Flexible Content field and trying to display a Jetpack Contact Form with no success.

    I tried 2 versions of your suggestion for testing and none of them worked.

    First attempt:

    if( have_rows('flexible_content') ):
        while ( have_rows('flexible_content') ) : the_row();
            if( get_row_layout() == 'full_column' ):
    	        $fullWidth = get_sub_field('full_width');
    	        echo apply_filters('the_content', $fullWidth);
            endif;
        endwhile;
    endif;

    Second attempt:

    <?php if( have_rows('flexible_content') ):
        while ( have_rows('flexible_content') ) : the_row();
            if( get_row_layout() == 'two_columns' ):
            	$half1 = get_sub_field('half_1');
            	$half2 = get_sub_field('half_2'); ?>
            	<div class="block group">
    			<div class="col1-2"><?php echo $half1 ? apply_filters('the_content', $half1) : '&nbsp;'; ?></div>
    			<div class="col1-2 last"><?php echo $half2 ? apply_filters('the_content', $half2) : '&nbsp;'; ?></div>
    		</div>
            <?php endif;
        endwhile;
    endif; ?>

    If you can take glance:
    http://texeurop.prompt-dev.com/contact/

    Versions running:
    WP 4.1
    ACF 5.1.8

  • Tried that way and still no luck. It is still saying there are no rows found when there are rows.

    <?php if( have_rows('layout_section') ): ?>
    
        <?php while ( have_rows('layout_section') ) : ?>
    
            <?php the_row(); ?>
    
            <?php if (get_sub_field('layout_section_type') == "feat_section") { ?>
    
                <p>Featured Section</p>
    
            <?php } elseif ( get_sub_field('layout_section_type') == "feat2" ) { ?>
    
                <p>Featured Section 2</p>
    
            <?php } elseif ( get_sub_field('layout_section_type') == "feat3" ) { ?>
    
                <p>Featured Section 3</p>
    
            <?php } else { ?>
    
                <p>Normal Section</p>
    
            <?php } ?>
    
        <?php endwhile; ?>
    
    <?php
    else :
        echo '<p>No Rows Found</p>';
        // no rows found
    endif;
    ?>

    Here are the config pages. First one of the repeater field itself

    The layout type options

    Just using it for text at the moment for debugging

  • Probably its not correct query (while…). Does it shows for example the_title(); ? Maybe the problem is not with acf 🙂

  • If I understood you correctly you can choose each custom fields group location. Under the fields you will find location (rules), so just choose “show field group if” is equal to post.

  • If I understood correctly you can try this. Just insert each field as array line after ‘relation’ and when use wp_query loop.

    $searchkey = 'yourwordhere';
    $args = array(
      'post_type'=> 'cpt_title',
      'posts_per_page' => -1,
      'meta_query' => array(
      'relation' => 'OR',
       array('key' => 'acf_field_name_here1','value' => $searchkey,'compare' => 'LIKE'),
       array('key' => 'acf_field_name_here2','value' => $searchkey,'compare' => 'LIKE')
       )    
    );
    
    $wp_query = new WP_Query($args);
    ?>
  • Thanks mediawerk 🙂 Looks like really good solution!!!

    Meanwhile i’m actually came up with wp query and meta key solution, however not sure what should i do in order to have all modules_%_text as keys (can’t get it working, without adding EACH line of them like 0,1,2…).

    $args = array(
      'post_type'=> 'post',
      'paged'    => $paged,
      'posts_per_page' => 9,
      'meta_query' => array(
      'relation' => 'OR',
       array('key' => 'modules_0_text','value' => $_GET['word'],'compare' => 'LIKE'),
       array('key' => 'modules_1_text','value' => $_GET['word'],'compare' => 'LIKE'),
       array('key' => 'modules_2_text','value' => $_GET['word'],'compare' => 'LIKE'), 
    );
    
    $search = new WP_Query($args);

    Here $_GET[‘word’] is custom url parameter value (instead of s=value)

  • hope i understand you right. (i had done core search ability by a workaround)
    if you dont use the normal content field of WP, then you could try something like that:

    function my_acf_update_text($post_id) {
    		
    if( have_rows('my_custominhalt') ):
    
         // loop through the rows of data
    	while ( have_rows('my_custominhalt') ) : the_row();
          
    	        $my_search="";
    	        if( get_row_layout() == 'text-block' ){
    	        $my_subtitle = get_sub_field('my_subtitle');        
    	        $my_content = get_sub_field('my_text_content');
    	        $my_search = '<h3>'.$my_subtitle.'</h3><p>'.$my_content.'</p>';
    	        }
    	             
    	        if( get_row_layout() == 'text-image-block' ){
    	        $my_subtitle = get_sub_field('my_subtitle');        
    	        $my_content = get_sub_field('my_imagetext');
    	        $my_search = '<h3>'.$my_subtitle.'</h3><p>'.$my_content.'</p>';       
    		}
    		$my_search_full = $my_search_full.' '.$my_search;
    	endwhile; 
    endif;
    	
    	// update post with the post_content created from 
    	$my_post = array('ID'=> $post_id,'post_content' => $my_search_full);
    
    remove_action('save_post', 'my_acf_update_text');
    wp_update_post( $my_post );
    add_action('save_post', 'my_acf_update_text');
    
    }
    add_action('save_post', 'my_acf_update_text');

    place it into your plugin, or functions.php
    what it does : it create a action that loop through all flexible fields with text, and save them to post_content. thanks to that i am able to search content by core function.

    hope that help you too (of course you need to adjust it to fit your needs)
    be careful, it overwrite anything inside post_content(core-wysiwyg of WP)
    you also need to re-save every post before it works, because only after save content is inserted into post_content

    if you need core-wysiwyg, then create a additional field and save the loop into that field. basically it would be easier to search only inside a single field instead of a repeater/flexible field

  • Hi,
    doesn’t work.

    in function.php:
    add_action(‘pre_get_posts’, ‘my_pre_get_posts’);

    function my_pre_get_posts( $query )
    {
    // validate
    if( is_admin() )
    {
    return;
    }

    if( !$query->is_main_query() )
    {
    return;
    }

    $meta_query = $query->get(‘meta_query’);
    if( !empty($_GET[‘auswahl’]) )
    {
    $bedrooms = explode(‘,’, $_GET[‘auswahl’]);

    //Add our meta query to the original meta queries
    $meta_query[] = array(
    ‘key’ => ‘p_reihe’,
    ‘value’ => $bedrooms,
    ‘compare’ => ‘IN’,
    );

    $bathrooms = explode(‘,’, $_GET[‘bathrooms’]);
    $meta_query[] = array(
    ‘key’ => ‘p_energieklasse’,
    ‘value’ => $bathrooms,
    ‘compare’ => ‘IN’,
    );
    }

    // update the meta query args
    $query->set(‘meta_query’, $meta_query);

    // always return
    return;

    }

    in archive.php:

    <div id=”search-houses”>
    <?php
    $field = get_field_object(‘p_reihe’);
    $values = isset($_GET[‘p_reihe’]) ? explode(‘,’, $_GET[‘p_reihe’]) : array();
    ?>

      <?php foreach( $field[‘choices’] as $choice_value => $choice_label ): ?>

    • <input type=”checkbox” value=”<?php echo $choice_value; ?>” <?php if( in_array($choice_value, $values) ): ?>checked=”checked”<?php endif; ?> /> <?php echo $choice_label; ?>
    • <?php endforeach; ?>

      <?php
      $field = get_field_object(‘p_energieklasse’);
      $values = isset($_GET[‘p_energieklasse’]) ? explode(‘,’, $_GET[‘p_energieklasse’]) : array();
      ?>
      <?php foreach( $field[‘choices’] as $choice_value => $choice_label ): ?>

    • <input type=”checkbox” value=”<?php echo $choice_value; ?>” <?php if( in_array($choice_value, $values) ): ?>checked=”checked”<?php endif; ?> /> <?php echo $choice_label; ?>
    • <?php endforeach; ?>

    </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(‘http://www.jemaniblue.ch/kategorie/handbrausen/?auswahl=&#8217; + vals);

    console.log( vals );

    });

    })(jQuery);
    </script>

  • if you talk about frontend, than place your code inside a if-loop like that:

    <?php 
    $custom_format = get_field('custom_format');
    if($custom_format == "option2"){
     if( get_field ('custom_infotext') ) : ?>;
      <p class="custominfo">
       <?php the_field('custom_infotext'); ?>
      </p>
     <?php endif; 
    }?>

    replace custom_format with your fieldname, and option2 with the value of option2

  • you need to do something like this:
    the key is = to loop first through all post, save marker/values into an array (without echo something), output one single map, and output the markers from saved array

    <?php 
    $the_query_map = new WP_Query( array( 'post_type' => 'event', 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'menu_order' ) );
    
    if($the_query_map->have_posts()) :
    while($the_query_map->have_posts()):
    $the_query_map->the_post();
    $the_ID = get_the_ID();
    $get_google_map = get_field('event_map', $value);
    
    $output_map[$the_ID]['map'] = '<div class="marker" data-lat="'.$get_google_map['lat'].'" data-lng="'.$get_google_map['lng'].'"></div>';
    
    endwhile; endif;
    wp_reset_postdata();
    
    ?><div class="acf-map"><?php
    foreach( $output_map as $key => $map_marker ):
    	echo $map_marker['map'];
    	endforeach;
    	?>
    </div>

    you need to adapt my code that it fit your needs, but i hope with that help you can do it at your own.

  • Updated to 5.1.8. Deleted the Page I was adding fields to and started a fresh Field Group. It still won’t save and I get this from WP:

    Warning: Illegal string offset 'acfcloneindex' in /Users/Phil/Sites/augustblume/wp-content/plugins/advanced-custom-fields-pro/pro/fields/repeater.php on line 156
    
    Notice: Array to string conversion in /Users/Phil/Sites/augustblume/wp-content/plugins/advanced-custom-fields-pro/pro/fields/repeater.php on line 156
    
    Warning: Invalid argument supplied for foreach() in /Users/Phil/Sites/augustblume/wp-content/plugins/advanced-custom-fields-pro/pro/fields/repeater.php on line 255

    and then when I try to Add a Row, I get this in the JS:

    [Error] TypeError: undefined is not an object (evaluating '$(this).get(0).outerHTML')
    	outerHTML (acf-input.js, line 288)
    	add (acf-pro-input.js, line 377)
    	doEvent (acf-input.js, line 1866)
    	(anonymous function) (acf-input.js, line 1805)
    	dispatch (jquery.js, line 3)
    	handle (jquery.js, line 3) 
  • I know this post is from a while ago now but I had a similar issue. I solved it like so:

        <?php if (have_rows('flexible_content')) : 
    
            while (have_rows('flexible_content')) : the_row();
    
               if (get_row_layout() == 'images_row'):
    
                   $header = get_sub_field('heading'); ?>
                   <div class="block-text-centered">
                        <h2 class="upper grey"><?php echo $header;?></h2>
                   </div>
    
                   <?php $rows = get_sub_field('images');
    
                    if ($rows) : ?>
                        <div class="pure-g">
                        <?php foreach ($rows as $row) : $img = wp_get_attachment_image_src($row['ID'], 'thumbnail'); ?>
                            <div class="pure-u-1-5 client-logo">
                                <img src="<?php echo $img[0]; ?>" alt="<?php echo $row['alt']; ?>">
                            </div>
                    <?php endforeach; ?>
                        </div>
                    <?php endif;
    
                endif; 
    
            endwhile;
    
        else :
    
        endif; ?>
    
  • Actually I just updated to ACF 5.1.8 and the sync still does it.

    We have production- and staging servers. Locally we develop on Vagrant.
    We git everything to bitbucket and sync fields between vagrants and servers through the ACF json files.

    On the production server, the customer is adding content, and we respond to requests and bugs by fixing them locally, pushing, bambooing to stage and then when stable bambooing to prod. To get the changes locally we use WP Sync DB to pull the database from prod to dev and then sync the json to get our ACF to the latest state.

    I’ve had to use https://github.com/FreshFlesh/ACF-Sync to get it to work, because when I try to use the ACF bundled sync it acts really, really weird.

    What it does is sometimes duplicating fields, and then loosing repeater subfields. This might not be a catastrophe if it didn’t arbitrarily make the json explode at the same time. Now counting three times, I’ve been in the position to have to reset to earlier commit, backing up the json, pulling myself back to HEAD and then pulling the DB all over again, and firing up the ACF-Sync plugin to do what ACF should be able to do just as well.

    ** Hey Eliot **, I think the culprit here might be that you try to do too much in one go. You try to sync both ways, don’t you? First pulling the json into ACF, and then saving a new json. So if operation one creates a problem, then operation two gets equally fu**** up… I would like the option of pulling one way only, letting the json stay untouched, that way I have something to fall back on if the fecal matter hits the rotating impeller.

    Could you separate the sync to db and sync to json from each other?

    I think I will start at ticket…

  • Hi brendan,
    I’m having similar problem, I cann’t show ACF fields content, only WordPress “content” textarea value is shown, could you help me?
    My code:

    
        $args       = array( 'post_type' => 'page', 'name' => 'movies', 'post_status' => 'publish' );
        $wp_query   = new WP_Query( $args );
        $output     = "";
    
        while ( $wp_query->have_posts() ) {
            $wp_query->the_post();
            $output .= apply_filters('the_content', get_the_content());    
        }
        
        wp_reset_query();
    
        return $output;

    Thank you

  • This reply has been marked as private.
  • Thanks ractoon

    I did all the instruction
    but isn’t get the right valid that entered from the backend

    for the first load, it’s render the valid address but quickly return the wrong address

  • hi
    thank you for this suggestion, but it doesn´t work for me

    <div class="entry-content">
        		<?php the_content(); ?>
    		<?php
    			wp_link_pages( array(
    				'before' => '<div class="page-links">' . __( 'Pages:', 'pictorico' ),
    				'after'  => '</div>',
    			) );
    		?>
            <?php if(get_field('spalten')): ?>
              <?php while(has_sub_field('spalten')): ?>
              <div class="columns">
              <div class="col-left"><?php 
    		  $wysiwyg = the_sub_field('linke_spalte', false, false); 
    		  echo apply_filters('the_content', $wysiwyg);
    		  ?></div>
              <div class="col-right"><?php 
    		  $wysiwyg = the_sub_field('rechte_spalte', false, false); 
    		  echo apply_filters('the_content', $wysiwyg);
    		  ?></div>
              </div>
              <?php endwhile; ?>
              <?php endif; ?>
    	</div><!-- .entry-content -->

    http://wp.bieblwerk.de/agentur/
    I´m using a repeater field, are ther any other options?
    Thank you very much

Viewing 25 results - 17,251 through 17,275 (of 21,345 total)