Support

Account

Forum Replies Created

  • I’ve made some progress – the sort now works but since there’s a ‘foreach’, the entire content is repeated. I have 8 sortable rows with subcontent right now, and everything is printed 8 times with the code below (but now sorted correctly in a descending order):

    <?php 
    		// check for rows (parent repeater)
    		if( have_rows('jc') ): 
    		
    		// get repeater field data
    		$jc = get_field('jc');
    		
    		// vars
    		$order = array();
    		
    		// populate order
    		foreach( $jc as $i => $row ) {
    			
    			$order[ $i ] = $row['id'];
    			
    		}
    		
    		// multisort
    		array_multisort( $order, SORT_DESC, $jc );
    		
    		// loop through repeater
    		if( $jc ): 
    		
    		?>
    			<div class="su-accordion">
    	
    				<?php 
    					// loop through rows (parent repeater)
    					while( have_rows('jc') ): the_row(); ?>
    					
    					<?php foreach( $jc as $i => $row ): ?>
    						
    						<div class="su-spoiler su-spoiler-style-simple su-spoiler-icon-plus su-spoiler-closed">
    							<div class="su-spoiler-title">
    								<?php echo $row['id']; ?><?php echo $row['month_year']; ?>
    							</div><!-- / spoiler title -->
    							
    								<?php 
    									// check for rows (sub repeater)
    									if( have_rows('attachments') ): ?>
    									
    									<div class="su-spoiler-content su-clearfix">
    										<?php 
    											// loop through rows (sub repeater)
    											while( have_rows('attachments') ): the_row();
    											
    											$file = get_sub_field('file');
    											
    											if( $file ): 
    											
    												// vars
    												$url = $file['url'];
    												$title = $file['title'];
    											
    												?>
    												
    												<p>
    													<a href="<?php echo $url; ?>" target="_blank">
    														<?php echo $title; ?>
    													</a>
    												</p>
    												
    												<?php endif; ?>
    												
    										<?php endwhile; ?>
    									</div><!-- / spoiler content -->
    								<?php endif; //if( get_sub_field('month_year') ): ?>
    						</div>
    						
    						<?php endforeach; ?>
    			
    				<?php endwhile; // while( has_sub_field('jc') ): ?>
    			</div>
    		<?php endif; // if( get_field('jc') ): ?>
    		<?php endif; // if( get_field('jc') ): ?>
    
  • Fantastic! Thank you 🙂

  • Oops! Sorry, editor now enabled.

    I also just tried with the added _sub, but no luck.

  • This reply has been marked as private.
  • This reply has been marked as private.
  • I did replace ‘field_name’ but now everything disappeared, nothing at all is showing.

    <main id="main" class="site-main" role="main">	
    <?php
    while ( have_posts() ) : the_post();
    
    get_template_part( 'template-parts/content', 'page' );
    
    // If comments are open or we have at least one comment, load up the comment template.
    if ( comments_open() || get_comments_number() ) :
    comments_template();
    endif;
    
    endwhile; // End of the loop.
    ?>
    
    <?php while( have_rows('person') ): the_row();
    $image_url = get_sub_field('headshot');
    $name = get_sub_field('name');
    $credentials = get_sub_field('credentials');
    $link = get_sub_field('link');
    				
    $expertise = get_field_object('expertise');
    $value = $field['value'];
    $choices = $field['choices'];
    if( $value ):
    ?>
    						
    <div class="person">
    <div class="col-sm-4 col-xs-12 text-center">
    <div class="headshot-container">
    <img src="<?php echo $image_url; ?>" alt="<?php echo $name; ?>" />
    </div>
    <div class="name">
    <?php echo $name; ?>
    </div>
    <div class="credentials">
    <?php echo $credentials; ?>
    </div>
    <div class="expertise">
    Expertise:
    <?php foreach( $value as $v ): ?>
    <div><?php echo $choices[ $v ]; ?></div>
    <?php endforeach; ?>
    </div>
    
    <a href="<?php echo $link; ?>" class="link">View Profile</a>
    </div>
    </div>
    <?php endif; ?>
    <?php endwhile; ?>
    
    </main><!-- #main -->
  • James,
    I don’t understand what has to go in place of [‘value’] and [‘choices’] in this example:

    <?php 
    $field = get_field_object('field_name');
    $value = $field['value'];
    $choices = $field['choices'];
    
    if( $value ): ?>
    <ul>
    <?php foreach( $value as $v ): ?>
    <li>
    <?php echo $choices[ $v ]; ?>
    </li>
    <?php endforeach; ?>
    </ul>
    <?php endif; ?>

    Should I leave them as-is?

    Thank you

  • Hi,
    sorry, should’ve been more clear.

    Everything works except the field that contains checkbox values outputs the word “array” and not the actual values.

  • I’m not sure if the sequence matters, but I deactivated Tiny, upgraded it, then reactivated it again. Visual/Text switch tabs are working for me.

  • TinyMCE updated the plugin last night, that fixed it for me.

  • Yes, it’s a 3.9 issue. Everything was fine before the upgrade.

  • Same here, TinyMCE breaks down. These are the errors I’m getting:

    Warning: array_diff(): Argument #2 is not an array in /home/site/public_html/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 308

    Warning: array_merge(): Argument #1 is not an array in /home/site/public_html/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 309

    Warning: array_diff(): Argument #2 is not an array in /home/site/public_html/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 319

    Warning: array_merge(): Argument #1 is not an array in /home/site/public_html/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 320

    Warning: implode(): Invalid arguments passed in /home/site/public_html/wp-content/plugins/advanced-custom-fields/core/controllers/input.php on line 94

    Warning: implode(): Invalid arguments passed in /home/site/public_html/wp-content/plugins/advanced-custom-fields/core/controllers/input.php on line 94

    Warning: implode(): Invalid arguments passed in /home/site/public_html/wp-content/plugins/advanced-custom-fields/core/controllers/input.php on line 94

    Warning: implode(): Invalid arguments passed in /home/site/public_html/wp-content/plugins/advanced-custom-fields/core/controllers/input.php on line 94

  • Hi Elliot,
    I figured it out, thanks.

  • I fixed this by adding the following to my stylesheet:

    .gm-style img { max-width: none; }

  • Awesome, thanks!
    Was considering another plugin but ACF is always the cleaner and more flexible way to go. Love it 🙂

  • On the off chance that someone else may be looking for this, here’s my solution.

    It checks whether the field exists, then outputs 10 RSS feed items including title and full content.

    <?php $blogfeed = get_post_meta($post->ID, ‘blog_feed’, true);
    if($blogfeed) : ?>
    
    <?php
    include_once(ABSPATH.WPINC.’/rss.php’); // path to include script
    $feed = fetch_rss($blogfeed); // specify feed url
    $items = array_slice($feed->items, 0, 10); // specify first and last item
    ?>
    
    <?php if (!empty($items)) : ?>
    <?php foreach ($items as $item) : ?>
    <div class=”feed-item”>
    <h4>” target=”_blank”><?php echo $item['title']; ?></h4>
    <p><?php echo $item['atom_content']; ?></p>
    </div>
    <?php endforeach; ?>
    
    <?php endif; ?>
  • Turns out it pulls up the feed just as I entered above, but it doesn’t quite work:

    – If I hard-code a URL, it pulls up the feed items info
    – but when I use ACF, it prints the feed URL and then gives an error:

    Warning: array_slice() expects parameter 1 to be array, null given in myfile.php

    It’s like it outputs the feed URL differently than a hardcoded one. get_field didn’t do anything at all.

    What’s the proper way to include feed URL in there so it would be processed as it should?

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