Support

Account

Forum Replies Created

  • Ok I sorted it out myself. You need to use named meta query.

    <?php // Meta query for tab
    	$current_date = date('Ymd');
    	$future_date = date('Ymd', strtotime('+6 days'));
    
    	$args = [
    	    'post_type' => 'events',
    	    'post_status' => 'publish',
    	    'posts_per_page' => 12,
    	    'meta_query' => array(
            'relation' => 'AND',
    	        'date_meta' => array(
    	           	'key' => 'event_date',
    	            'value' => [$current_date, $future_date], // Use an array to specify a range
    	            'compare' => 'BETWEEN', // Use BETWEEN to specify a range
    	            'type' => 'DATE',
    	        ),
    	        'time_meta' => array(
    	            'key' => 'start_at', // 'start_at' is the custom field storing the time value
    	            'type' => 'TIME' // Use 'TIME' meta type for 'start_at' field
    	        ),
    	    ),
    	    'orderby' => [
    	        'date_meta' => 'ASC', // Order by 'event_date' in ascending order
    	        'time_meta' => 'ASC' // Then order by 'start_at' in ascending order
    	    ]
    	];
    
    	include(locate_template('template-parts/tabs-inner-include.php', false, false));
    ?>
    
  • I had the same problem, wanted to limit current term in custom taxonomy in wp-admin.

    Here is my solution.

    // Show 2000 posts pre ajax call, change sort, limit to current taxonomy and term id
    add_filter('acf/fields/relationship/query/name=author_sort_list', 'authors_fields_relationship_query', 10, 3);
    function authors_fields_relationship_query( $args, $field, $post_id ) {
        
        $url     = wp_get_referer();
        $parts   = parse_url($url);
        parse_str($parts['query'], $query);
    
        $term_id = $query['tag_ID'];
        $taxonomy = $query['taxonomy'];
        if ( isset($taxonomy) && isset($term_id)) {
    
            $args['tax_query'] = array(
                array(
                    'taxonomy' => $taxonomy,
                    'field' => 'term_id',
                    'terms' => $term_id,
                    'operator' => 'IN'
                )
            );
        }
    
        $args['posts_per_page'] = 2000;
        $args['orderby'] = 'date';
        $args['order'] = 'ASC';
    
        return $args;
    }
    
  • @hube2 , We are talking about true / false field. Empty value doesn’t work too.

  • Hi,

    1. ok will have a look.
    2. ok
    3. We have database of authors as a custom post “authors”.
    I want to be able (in wp-admin) to:
    a. add new authors and sort them (that is possible as a standard)
    b. automatically add “newly added authors in the authors list” to the end of the selection field (right panel)

  • $scheduleloop->reset_postdata() worked. It won’t be included from any other place so this will do. Thank you very much!

  • I would like to report it too. Could you guys fix this issue ?
    If you want to create tabs headers and tabs content you need to loop it twice with the same reaptear.

    This creates a problem. In second loop I get 1 row from first loop with empty content. And that breaks tab functionality.

  • And this is how it looks like.

  • Best example of not to code very late 🙂

  • Looks like the problem lies in this.

    
    This:
    <?php if( have_rows('newsletter_files_section', $stronaPdfy) ): the_row(); ?>
    
        <?php while( have_rows('newsletter_files_section', $stronaPdfy) ): the_row(); ?>
    
    Should be like this:
    
    <?php if( have_rows('newsletter_files_section') ): ?>
    
        <?php while( have_rows('newsletter_files_section') ): the_row(); ?>
    
  • Returns Null, weird.
    Will send you all files via email.

  • John, you guys are legends. That is just super support 🙂
    Cheers.

  • This is archive’s custom template (archive-kanaly_premium.php) for custom post type. There is no other loop, I use that system for all other types of posts, pages and archives.

  • Looks like this

    <?php get_header(); ?>
    <div id="innerwrapper" class="page">
    	<div class="container">
    		<div class="row">
    			<div id="lewaKolumna" class="col-xs-3 col-sm-3 col-md-3 hidden-xs hidden-sm">
    				<div class="sideModule">
    					<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(17) ) : else : ?>
    					<?php endif; ?>
    				</div>
    			</div>
    			<div id="prawaKolumna" role="main" class="col-xs-12 col-sm-9 col-md-9">
    			<div class="catHeader">
    				<div id="breadcrumbs">
    					<?php if(function_exists('bcn_display'))
    					{
    						bcn_display();
    					}?>
    				</div>
    				<div class="headerImg">
    					<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(14) ) : else : ?>
    					<?php endif; ?>
    				</div>
    				<div class="headerCatDesc">
    					<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(15) ) : else : ?>
    					<?php endif; ?>
    				</div>
    			</div>
    			<div id="podstrona">
    				<div class="contentBodyWrapper kanalyPremium">
    				<?php
    				/* Główna pętla */
    				$args = array(
    					'post_type' => 'kanaly_premium',
    					'posts_per_page' => -1,
    					'orderby' => 'date',
    					'order' => 'DESC',
    				);
    				
    				$fullnewsloop = new WP_Query($args);
    				if($fullnewsloop->have_posts()): 
    				while($fullnewsloop->have_posts()): $fullnewsloop->the_post(); ?>
    
    					<div class="pakietBoxLista row">
    						<div class="col-xs-12 premiumTitle">
    							<h2><?php echo the_title(); ?></h2>
    						</div>
    						<div class="col-xs-12 col-md-3">
    							<?php if(get_field('okladka_pakietu_premium')): ?>
    								<?php $okladkaPremium = get_field('okladka_pakietu_premium'); ?>
    								<div class="headerImg">
    									<img src="<?php echo $okladkaPremium['sizes']['medium'] ?>" />
    								</div>
    							<?php endif; ?>
    						</div>
    						<div class="col-xs-12 col-md-9">
    							<?php if( get_field('krotki_opis_pakietu_premium')): ?>
    								<?php the_field('krotki_opis_pakietu_premium'); ?>
    							<?php endif; ?>
    							
    							<ul id="pakietBoxLista">
    							<?php // check current row layout ?>
    								<?php if( have_rows('programy_lista') ): ?>
    									<?php while ( have_rows('programy_lista') ) : the_row(); ?>   
    										<?php
    										$post_objects = get_sub_field('kanal');
    										if( $post_objects ): ?>
    											<?php foreach( $post_objects as $post): // variable must be called $post (IMPORTANT) ?>
    												<?php setup_postdata($post); ?>
    													<li class="kanalTelwizyjny">
    														<section class="kanalWrapper">
    														<?php //Elementy kanału ?>
    														<?php if(get_field('klasa_obrazka_kanalu', $post->ID)): ?>
    															<div class="sprite sprite-premium sprite-premium-<?php the_field('klasa_obrazka_kanalu', $post->ID); ?>"></div>
    														<?php else: ?>
    															<div class="sprite sprite-premium sprite-premium-<?php echo $post->post_name; ?>"></div>
    														<?php endif; ?>
    														<div class="kanalWrapperInner row row-eq-height">
    															<div class="col-md-3 col-sm-4 imgPrevBlock">
    																<?php if( get_field('pakiety_dostepne_w', $post->ID)): ?>
    																	<div class="dostepnyW"><p>Dostępne w pakiecie:</p><?php the_field('pakiety_dostepne_w', $post->ID); ?></div>
    																<?php endif; ?>
    																<?php if( get_field('dostepny_na_kanale', $post->ID)): ?>
    																	<div class="dostepnyNa"><p>Dostępny na kanale:</p><?php the_field('dostepny_na_kanale', $post->ID); ?></div>
    																<?php endif; ?>
    																<?php if( get_field('kategoria_kanalu', $post->ID)): ?>
    																	<div class="kategoriaKanalu"><p>Kategoria:</p><?php the_field('kategoria_kanalu', $post->ID); ?></div>
    																<?php endif; ?>
    																<?php if( get_field('jakosc', $post->ID) == "Jakość SD" ): ?>
    																	<div class="wyborJakosci"><p><?php echo get_field('jakosc', $post->ID); ?></p></div>
    																<?php else: ?>
    																	<div class="wyborJakosci jakoscHD"><p><?php echo get_field('jakosc', $post->ID); ?></p></div>
    																<?php endif; ?>
    															</div>
    															<div class="col-md-9 col-sm-8 shortDescBlock">
    																<h3 class="catItemTitle">
    																	<?php the_title(); ?>
    																</h3>
    																<div class="catItemIntroText listaPremium">
    																	<?php the_content(); ?>
    																</div>																				
    															</div>
    														</div>
    														</section>
    													</li>
    											<?php endforeach; ?>
    											<?php // wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    										<?php endif; ?>
    									<?php endwhile; ?>
    								<?php endif; ?>		
    							</ul>
    							
    						</div>
    						<div class="col-xs-12 col-md-12 readMore">
    							<a class="btn pull-right" title="więcej" href="<?php echo get_permalink( $post->ID ); ?>">więcej</a>
    						</div>
    					</div>
    					
    				<?php 
    				endwhile;
    				endif;
    				?>
    				</div>
    			</div>
    		</div>
    		</div>	
    	</div>
    </div>
    <?php get_footer(); ?>
    
  • I just noticed that by commenting wp_reset_postdata (at the end of the loop) there is no repeating of boxes, but get_permalink( $post->ID ) does’t work, all 3 posts link to same single post.

    
    <?php endforeach; ?>
    <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    endif; ?>
    
  • I am bit closer to my goal. At this moment I just can’t access acf fields from the posts listed in the page via repeater and flexi content. Weird …

    This is my new code that works.
    Please see attached screens of my setup.

    <ul class="pageBodyKanaly">
    								<?php // check if the flexible content field has rows of data ?>
    								<?php if( have_rows('kanaly_telewizyjne_na_stronie') ): ?>
    								
    									<?php // loop through the rows of data ?>
    									<?php while ( have_rows('kanaly_telewizyjne_na_stronie') ) : the_row(); ?>
    										<li class="kanalElement">
    											<?php // check current row layout ?>
    											<?php if( get_row_layout() == 'kategoria_kanalu' ):  ?>
    												
    												<div class="kategoriaKanalow">
    													<?php if( get_sub_field('nazwa_kategorii_kanalu')): ?>
    														<h2><?php the_sub_field('nazwa_kategorii_kanalu'); ?></h2>
    													<?php endif; ?>
    												</div>
    												
    												<section class="kanalyBody">
    													<?php if( have_rows('programy_lista') ): ?>
    														<ul id="kanaly">
    															<?php while ( have_rows('programy_lista') ) : the_row(); ?>   
    																<li>
    																	<?php
    																		$post_objects = get_sub_field('kanal');
    																		if( $post_objects ): ?>
    																			<ul>
    																			<?php foreach( $post_objects as $post): // variable must be called $post (IMPORTANT) ?>
    																				<?php setup_postdata($post); ?>
    																				<li>
    																					<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    																					<?php the_content(); ?>
    																					<?php if( get_sub_field('klasa_obrazka')): ?>
    																						<h5><?php the_sub_field('klasa_obrazka'); ?></h5>
    																					<?php endif; ?>
    																				</li>
    																			<?php endforeach; ?>
    																			</ul>
    																			<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    																		<?php endif; ?>
    																</li>
    															<?php endwhile; ?>
    															</ul>
    													<?php endif; ?>
    												</section>
    											<?php endif; ?>
    										</li>
    									<?php endwhile; ?>
    							</ul>
  • I want to create page which lists posts wit categories.

    Page has flexible content, which creates categories for selected posts.

    Posts have a acf fields.
    Posts are custom post type.
    So…
    I want to loop post object in repeater in flexible content.

  • I have notices that I have this function in my single.php

    add_action( 'acf/save_post', 'my_update_existing_post_data', 10 ); 
    	function my_update_existing_post_data( $post_id ) {
    
    		// Update existing post
    		$post = array(
    			'ID'           => $post_id,
    			'post_status'  => 'publish',
    			'post_title'   => wp_strip_all_tags($_POST['acf']['field_5464a2a2d9a50']), // Post Title ACF field key
    		);
    
    		// Update the post
    		$post_id = wp_update_post( $post );
    	}

    This is used to update posts title, but this also is used when editing with the form responsible for updating the shop details. And because of that I get my title empty.

    Any idea how to make those 2 work together ?

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