Support

Account

Forum Replies Created

  • OK, Well, I think I solved my problem. The following code added to the functions file will force the first accordion open.

    add_action('acf/input/admin_head', 'my_acf_input_admin_head');
    function my_acf_input_admin_head() {
    ?>
    <script type="text/javascript">
    jQuery(function(){
      jQuery('.acf-accordion').removeClass('-open');
      jQuery('.acf-accordion:first-of-type').addClass('-open');
    });
    </script>
    <?php
    }
  • I know this is old, but as a heads up, this worked perfectly. Thanks.

  • OK Here’s what I have tried. The concept that I am going with is that the “Page Link” custom field type stores the URL in a string and we just need to query by that meta value. But, it’s not working.

    Any ideas?

    
    <?php 
    $currentURL = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    
    $args = array(
    	'numberposts'	=> -1,
    	'post_type'		=> 'on_site_optimization',
    	'meta_query'	=> array(
    		'relation'		=> 'AND',
    		array(
    			'key'		=> 'website_parent',
    			'value'		=> $currentURL,
    			'compare'	=> 'LIKE'
    		),
    	)
    );
    
    // query
    $the_query = new WP_Query( $args );
    
    ?>
    <?php if( $the_query->have_posts() ): ?>
    	<ul>
    	<?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
    		<li>
    			<a href="<?php the_permalink(); ?>">
    				<?php the_title(); ?>
    			</a>
    		</li>
    	<?php endwhile; ?>
    	</ul>
    <?php endif; ?>
    
    <?php wp_reset_query(); ?>
    
  • Also, to get custom fields in the “ForEach” use the following
    <?php echo get_field('task_due_date', $tasks->ID); ?>

  • OK. I got this working. Here is my code for reference.

    <?php
    $tasks = get_posts(array(
    	'post_type' => 'task',
    	'meta_query' => array(
    		array(
    			'key' => 'task_parents', // name of custom field
    			'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
    			'compare' => 'LIKE'
    		)
    	)
    ));
    
    ?>
    <?php if( $tasks ): ?>
    	<table>
    	<?php foreach( $tasks as $tasks ):?>
    		<tr>
    			<td>
    				<a href="<?php echo get_permalink( $tasks->ID ); ?>">
    					<?php echo get_the_title( $tasks->ID ); ?>
    				</a>
    			</td>
    		</tr>
    	<?php endforeach; ?>
    	</table>
    <?php endif; ?>
Viewing 5 posts - 1 through 5 (of 5 total)