Support

Account

Forum Replies Created

  • Hi @imaginedd

    Thank you for showing the way 🙂

    I have tried that example code and now i have all events from each band on specific date. The problem is that i’m not sure how to sort it by time sub field.

    Here is the code:

    <?php
    $date = "20160620";
    // args
    $args = array(
    	'numberposts'	=> -1,
    	'post_type'		=> 'band',
    	'meta_query'	=> array(
    		'relation'		=> 'OR',
    		array(
    			'key'		=> 'events_%_date',
    			'compare'	=> '==',
    			'value'		=> $date,
    		)
    	)
    );
    
    $the_query = new WP_Query( $args );
    ?>
    
    <?php if( $the_query->have_posts() ): ?>
    	<div class="events">
    	<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    		<?php
    		if(have_rows('events')):
    		   while(have_rows('events')): the_row();
    			  if(get_sub_field('date') == $date):
    				 the_sub_field('time');
    				 echo ' - ';
    				 the_title();
    				 echo '<br>';
    			  endif;
    		   endwhile;
    		endif;
    		?>
    	<?php endwhile; ?>
    	</div>
    <?php endif; ?>
    
    <?php wp_reset_query();	 ?>

    By this code i’m getting such events lst:

    1500 – Band1 (1st show)
    1800 – Band 1 (2nd show)
    1400 – Band 2 (2nd show)
    1200 – Band 2 (1st show)

    I’m not sure how to use krsort() with repeater. Can you help me with this?

    Many thanks!

  • Yeah in this case. or just acf 5 pro pack with options page included.

  • 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.

  • Not sure what you want to achieve 🙂 You can create theme template only for portfolio page and use acf background field ONLY for that template.

  • Strange. Maybe some failure with plugin itself. I think you should write to support and open new ticket. Unless i don’t see something incorrect in your code.

  • Hm, the code looks ok, maybe you can try just this code and check if it returns anything.

    <?php
    if( have_rows('layout_section') ):
        while ( have_rows('layout_section') ) : the_row();
            the_sub_field('ENTER HERE SOME FIELD NAME WHERE YOU HAVE SOME TEXT');
        endwhile;
    else :
    endif;
    ?>
  • I think first lines should be:

    <?php if( have_rows('layout_section') ): ?>
    <?php while ( have_rows('layout_section') ) : ?>
    <?php the_row(); ?>

    instead of:

    <?php if( have_rows('layout_section') ): ?>
     <?php while(the_repeater_field('layout_section')): ?>
  • 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.

  • I have found out that it is the same as repeater field -> flexible_%_field. However if i’m adding it as flexible_0_field it works and if i’m adding flexible_%_field if don’t. Any ideas why it’s so?

  • it’s activated and you’ve logged in as administrator rights you probably should open support ticket OR try to choose standart WP theme and disable all other plugins.

  • Hi,

    You should setup options page and make field for portfolio background. When just use background field to portfolio template like this:

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

    In this case you will choose background only once, but it will be visible on each portfolio 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)

  • My final code for this issue:

    <?php if( have_rows('modules') ): ?> 
    <ul>
    
    <?php while ( have_rows('modules') ) : the_row();
    
    if( get_row_layout() == 'photo' ): 
    
    echo '<li>'.the_sub_field('menu_name') . '<li>';
    
    elseif( get_row_layout() == 'text' ): 
    
    echo '<li>' . the_sub_field('menu_name') .'</li>';
    
    endif; endwhile; ?>
    
    </ul>
    <?php endif;  // end modules has rows ?>

    It works perfectly. Thanks ractoon for your help. It was more easier when i was trying to do it 🙂

  • Yeahhhh 🙂 Actually it’s pretty simple solution. Just using the same source code and making output of only menu item sub_field, ignoring all other fields.

    Thanks ractoon for your help. I will try it and come back if its solved 🙂

Viewing 18 posts - 1 through 18 (of 18 total)