Support

Account

Forum Replies Created

  • It is correct, and I’ve double-checked to see that the 3 posts in that CPT each do have that field filled out.

  • Nope. This didn’t solve it (and there were some missing closing semi-colons).

    I also tried with “explode” instead of “implode” and it didn’t work.

    Here’s my current code:

    $args = array(
      'post_type' => 'locations',
      'posts_per_page' => -1
    );
    $query = new WP_Query($args);
    $facebook_ids = array();
    if ($query->have_posts()) {
      while($query->have_post()) {
        $query->the_post();
        $facebook_ids[] = get_field('facebook_group_name');
      }
      wp_reset_postdata();
    }
    echo explode(',', $facebook_ids);
  • This is in archive-locations.php

  • Thank you. This actually helped a lot. I’ve got it working correctly now. Much appreciated 🙂

  • No, this doesn’t seem to be working. The section of the code in question (venue) that’s not working isn’t a repeater in this case. It’s simply a post_object.

  • Ahhhhh…I see. Thank you. And I’m sorry I didn’t realize it was a purely PHP problem. I appreciate the help.

  • BAM! That code made the difference. I apologize for not having seen that error. Thank you LOADS!!! *MWUAH*

  • Those actually weren’t errors, as far as I can tell. The post type is called “post_staff”, not “staff”. So the column itself is appearing. The only problem I’m having is populating that column from ACF, which is why I thought this was an ACF issue, and not WP. All I’m needing is to get that field populated.

  • No dice (I’d actually tried that $post->ID at one point). I’ve also already reviewed that page from Elliot Condon.

    Any other ideas?

  • Many thanks. That helped loads 🙂

  • Hmmmm…still did not work. HOWEVER, I decided to just re-do that whole section (the tab content area) from scratch and in doing so was able to get it to work using a different method of grabbing the posts. Instead of ‘while’, I did ‘foreach’. I’m still not sure why the other way wasn’t working. I feel like it *should* have. But here’s what I got working (I can’t take *all* the credit…my programming-genius friend did help me here, but he’s just not always available).

    	<!-- Nav Tabs -->
    	<ul  class="nav nav-pills">
    		<?php if (have_rows('home_categories')) {
    			$i = 0;
        		while (have_rows('home_categories')) {
    	    		the_row();
    				$term = get_sub_field('categories'); ?>
    		<li class="<?php if ($i == 0) { echo ' active'; }?>"> 
    			<a href="#tab-pane-<?php echo $i; ?>" data-toggle="tab"><?php echo $term->name; ?></a>
    		</li>
    			<?php $i++;
    			}
    		} ?>
    	</ul>
    	
    	<!-- Tab Content -->
    	<div class="tab-content clearfix">
    		<?php 
    			
    			$home_categories = get_field("home_categories");
    		//	print_r($home_categories);
    			
    			foreach($home_categories as $key => $home_cat) {
    				
    				
    				$term_id = $home_cat['categories']->term_id;
    				$term_name = $home_cat['categories']->name;
    				
    				?>
    				<div class="tab-pane fade<?php if ($key == 0) { echo ' in active'; }?>" id="tab-pane-<?php echo $key; ?>">
    				<?php
    				
    				
    				$args = array(
    					'post_type' => 'post',
    					'tax_query' => array(
    						array(
    							'taxonomy' => $term->taxonomy,
    							'terms' => array($term_id)
    						)
    					),
    					'posts_per_page' => 5,
    					'orderby' => 'date',
    					'order' => 'ASC',
    				);
    				$query = new WP_Query( $args );
    				
    				foreach($query->posts as $post) {
    					
    					?>
    					
    						<a href="<?php echo get_permalink($post->ID); ?>"><?php echo get_the_post_thumbnail($post->ID, 'thumbnail', array('class' => 'img-responsive img-thumbnail')); ?></a>
    						<a href="<?php echo get_permalink($post->ID); ?>"><h3><?php echo get_the_title($post->ID); ?></h3></a>
    						<?php the_excerpt(); ?>
    					<?php
    					
    					
    				}
    								
    				?>
    				</div>
    				<?php	
    					
    					
    				
    			}			?>
    
    	</div>
  • Unfortunately no content is being created inside the tabs now at all, regardless of whether reset_rows() is in there. Before changing the args, I was getting content, just the *wrong* content. So I’m really confused now.

  • I should note that I have tried putting the reset_rows() bit right before Tab Content. It seems to be causing my page to slow to a crawl, and isn’t generating anything in that content area at all now.

  • I apologize for the delay in responding. I see the problem with the query and thank you there. However, I’m not understanding the reset_rows() item. Where, exactly, between the two loops does it go? Does it replace reset_postdata? Or does it go before or after that? I’m afraid this is one I haven’t run into before.

  • (I do have another client who purchased the Pro version and I’ve needed assistance with that before, so perhaps that’s why. No worries at all)

    Ah HA! The 2nd one worked great! Thank you SO very very much!

  • This reply has been marked as private.
  • Oooof…thought I’d responded to this days ago. My apologies.

    First, $quote is just a text field – a testimonial from a client. Second, I’m not sure how to export the json of the field group. Third, following is the full code for the shortcode. Note that I’ve since made a number of changes as I continued to work on things, but I still haven’t figured out how to get the quotes pulled in so I had temporarily pulled the code entirely. So where it says “Quote goes here”, that’s where the code above was.

    <?php
    //Add Featured Portfolio items shortcode //
    add_shortcode( 'featured_portfolio', 'display_featured_portfolio_items' );
    
    function display_featured_portfolio_items(){
    	
    	ob_start();
    	
    	// Define the query
    	$args = array(
    		'post_type' => 'pixieportfolio',
    		'post_status' => 'publish',
    		'orderby' => 'menu_order',
    		'meta_query'	=> array(
    			array(
    				'key'	  	=> 'featured_portfolio_item',
    				'value'	  	=> '1',
    				'compare' 	=> '=',
    			)
    		),
    		'meta_key' => '_thumbnail_id',
    		'posts_per_page' => 999
    	);
    	
    	$query = new WP_Query( $args );
    	$count = 0;
    
    // Carousel // ?>
    <!--<div class="more-button">
    	<a href="/portfolio-all/" class="btn btn-default btn-lg" type="button" role="button">More Projects</a>
    </div>-->
    
    <div id="featuredCarousel" class="carousel slide" data-ride="carousel" data-pause="hover">
    		
    	<!-- Indicators -->
    	<ol class="carousel-indicators">
    		
    		<?php while($query->have_posts()): $query->the_post(); ?>
    
                <li <?php if($count == 0){ echo 'class="active"';} ?> data-target="#featuredCarousel" data-slide-to="<?php echo $count++; ?>"></li>
    
              <?php endwhile; ?>
    	</ol>
    	
    	<div class="carousel-inner" role="listbox">
    		
    		<?php $count = 0;
    			
    			while ($query->have_posts()) : $query->the_post();
    			$count++;
    			$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'pp-home-portfolio' );
    			$url = $thumb['0'];
    			$values = get_field('tech_choices');
    			$terms = get_the_terms($post->ID, 'post_tag');
    			$custom = get_post_custom($post->ID);
    			$caption = get_field('caption', '');
    			$client =  get_field('client', '');
    			$project_url = get_field('project_url', '');
    			$date = get_field('date', ''); ?>
    		
    		<!-- Wrapper for slides -->
    		<div class="item <?php if ($count == 1) { echo 'active';} ?>" data-slide-number="<?php echo $count++; ?>" id="<? the_ID(); ?>">
    			<div class="item-image" style="background-image: url(<?=$url?>);" title="<?php the_title() ?>" data-toggle="modal" data-target="#myModal<?php echo $count; ?>"></div>
    			
    			<div class="project-details">
    				<div class="project-detail-border shadow-effect"></div>
    				<div class="project-detail">
    					<div class="top-detail">
    						<h4><?php the_title(); ?></h4>
    						<div class="short-description">
    							<?php $content = get_the_content();
    								echo wp_trim_words( $content , '20' );
    							?>
    						</div>
    					</div>
    					
    					<table class="table project">
    						<tr>
    								<td valign="middle" class="fifty">
    									<?php $terms_as_text = strip_tags( get_the_term_list( $wp_query->post->ID, 'pixie-portfolio-categories', '', ', ', '' ) );
    echo $terms_as_text;?>
    								</td>
    								
    								<td valign="middle" class="fifty">
    									<?php if( $values ) {
    										
    										if(in_array('WordPress', $values )){ ?>
    											<i class="fa fa-wordpress fa-2x" data-toggle="tooltip" title="Wordpress"></i>
    										<?php } if(in_array('HTML-5', $values )){ ?>
    											<i class="fa fa-html5 fa-2x" data-toggle="tooltip" title="HTML-5"></i>
    										<?php } if(in_array('CSS-3', $values )){ ?>
    											<i class="fa fa-css3 fa-2x" data-toggle="tooltip" title="CSS-3"></i>
    										<?php } if(in_array('Sportswear', $values )){ ?>
    											<i class="fa fa-bicycle fa-2x" data-toggle="tooltip" title="Sportswear"></i>
    										<?php } if(in_array('Adobe', $values )){ ?>
    											<i class="fa fa-paint-brush fa-2x" data-toggle="tooltip" title="Adobe"></i>
    										<?php } if(in_array('Code', $values )){ ?>
    											<i class="fa fa-code fa-2x" data-toggle="tooltip" title="Code"></i>
    										<?php } if(in_array('Ecommerce', $values )) { ?>
    											<i class="fa fa-database fa-2x" data-toggle="tooltip" title="MySQL"></i>
    										<?php }
    									} else {} ?>
    									
    								</td>
    							</tr>
    							
    							<tr>
    								<td colspan="2" class="more-info" data-toggle="modal" data-target="#myModal<?php echo $count; ?>">
    									<div class="view-project">View Project</div>
    								</td>
    							</tr>
    					</table>
    				</div>
    			</div>
    		</div>
    		
    		<!-- Modal -->
    		<div id="myModal<?php echo $count; ?>" class="modal fade" role="dialog" aria-labelledby="myModal<?php echo $count; ?>Label">
    			<div class="modal-dialog modal-lg" role="document">
    				
    				<!-- Modal content-->
    				<div class="modal-content">
    					<div class="modal-header">
    						<button type="button" class="close" data-dismiss="modal">&times;</button>
    						<h2 class="modal-title"><?php the_title() ?></h2>
    						<span>
    							<?php if( $terms ): ?>
    							<ul>
    								<?php foreach( $terms as $term ): ?>
    								<li><a href="<?php echo get_term_link( $term ); ?>"><?php echo $term->name; ?></a></li>
    								<?php $icon = get_field('creative_icon', $term->taxonomy . '_' . $term->term_id); echo $icon; ?>
    								<?php endforeach; ?>
    							</ul>
    							<?php endif; ?>
    						</span>
    					</div>
    					<div class="modal-body">
    						<div class="container-fluid">
    							<div class="row">
    								<div class="col-md-8">
    									<div>
    										<p class="post-meta gallery-list">
    											<?php if( $client ): ?>
    											<span class="pixie-date">
    												<span class="title">Client:</span> <?=$client?>
    											</span>
    											<?php endif;
    											
    											if ( $date ): ?>
    											<span class="post-cats">
    												<span class="title">Date:</span> <?=$date?>
    											</span>
    											<?php endif;
    											
    											if ( $values ) { ?>
    											<span class="post-comments">
    												<?php $values = get_field('tech_choices'); ?>
    												<span class="title">Tech used in this project:</span>
    												
    												<?php if(in_array('WordPress', $values )){ ?>
    												<i class="fa fa-wordpress fa-2x" data-toggle="tooltip" data-placement="bottom" title="WordPress"></i>
    												<? }
    													
    												if(in_array('HTML-5', $values )){ ?>
    												<i class="fa fa-html5 fa-2x" data-toggle="tooltip" data-placement="bottom" title="HTML5"></i>
    												<? }
    													
    												if(in_array('CSS-3', $values )){ ?>
    												<i class="fa fa-css3 fa-2x" data-toggle="tooltip" data-placement="bottom" title="CSS3"></i>
    												<? }
    													
    												if(in_array('Sportswear', $values )){ ?>
    												<i class="fa fa-bicycle fa-2x" data-toggle="tooltip" data-placement="bottom" title="Sportswear"></i>
    												<? }
    												
    												if(in_array('Adobe', $values )){ ?>
    												<i class="fa fa-paint-brush fa-2x" data-toggle="tooltip" data-placement="bottom" title="Illustrator and/or Photoshop"></i>
    												<? }
    													
    												if(in_array('Code', $values )){ ?>
    												<i class="fa fa-code fa-2x" data-toggle="tooltip" data-placement="bottom" title="PHP, JQuery, etc."></i>
    												<? }
    													
    												if(in_array('Ecommerce', $values )){ ?>
    												<i class="fa fa-shopping-cart fa-2x" data-toggle="tooltip" data-placement="bottom" title="ECommerce"></i>
    												<? }
    												
    												if(in_array('MySQL', $values )){ ?>
    												<i class="fa fa-database fa-2x" data-toggle="tooltip" data-placement="bottom" title="MySQL"></i>
    												<? } ?>
    											</span>
    											<?php } ?>
    										</p>
    									</div>
    									
    									<?php echo the_content(); ?>
    									
    									<blockquote class="testimonial">
    									
    										QUOTE GOES HERE
    								
    									</blockquote>
    								</div>
    								
    								<div class="col-md-4">
    									<div class="gallery">
    									
    									<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'darwin-modal-main' );
    									$url = $thumb['0'];
    									$thumb2 = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large' );
    									$url2 = $thumb2['0'];
    									$c = 0; ?>
    									<a href="<?=$url2?>" class="group" id="port_gal" rel="group<?php echo $c; ?>">
    										<img src="<?=$url?>" width="300" height="300">
    									</a>
    									
    									<?php $images = get_field('gallery_images');
    										if( $images ) {
    											foreach( $images as $image ) {
    									?>
    									<a href="<?php echo $image['sizes']['large'] ?>" class="group" id="port_gal"  rel="group<?php echo $c; ?>">
    										<img src="<?php echo $image['sizes']['darwin-modal-thumb'] ?>" alt="<?php $image['alt'] ?>" />
    									</a>
    											<?php }
    										} ?>
    									</div>
    									
    									<div class="website-button">
    									
    									<?php if ( $project_url ): ?>
    									<a class="btn btn-default" href="<?=$project_url?>" target="_blank" role="button">Visit Website</a>
    									<?php endif; ?>
    									</div>
    								</div>
    								
    							</div>
    						</div>
    					</div>
    					<div class="modal-footer">
    						<button type="button" class="close" data-dismiss="modal">&times;</button>
    					</div>
    				</div>
    			</div>
    		</div>
    		
    		<?php endwhile; ?>
    		
    	</div>
    	<?php wp_reset_query(); ?>
    </div>
    
    <?php return ob_get_clean(); } ?>
  • I think my problem is similar to what’s been going on here, but I’m still coming up blank.

    I have a taxonomy field (checkbox, so multiple items can be chosen) inside a custom post type. So far so good. My query displays the selected taxonomies.

    But within those custom taxonomy terms I’ve added a FontAwesome field, so each term has an icon associated with it.

    What I’m trying to do is display all icons of terms selected within the custom post.

    Here’s my code so far (like I said, the term name itself is displaying just fine, but I want the icon associated with that term to be displaying):

    <?php $terms = get_field('tech_choices');
    $cat_icon = get_field('creative_icon', $queried_object); ?>
    <span>
    	<?php if( $terms ): ?>
    	<ul>
    		<?php foreach( $terms as $term ): ?>
    		<li><a href="<?php echo get_term_link( $term ); ?>"><?php echo $term->name; ?></a></li>
    		<?php $icon = get_field('creative_icon', $term->taxonomy . '_' . $term->term_id); echo $icon; ?>
    		<?php endforeach; ?>
    	</ul>
    	<?php endif; ?>
    </span>
  • Nevermind. It was yet another late night when I should have stopped working hours earlier and my brain was fried. Truly, I’m not sure what had happened. I hadn’t changed the code from when it had been working. But I just went and re-did it and it’s clearly different. Works fine now.

    If anyone else needs it, even though I’d already technically had this answered in a post a few days ago (see? I said I was tired. I didn’t even remember that until this morning):

    <nav>
    	<a href="#introduction" class="inactive"><i class="fa fa-home fa-2x"></i><span>Home</span></a>
    		<?php if( have_rows('home', 'option') ): $i = 0;
    			while ( have_rows('home', 'option') ) : the_row();
    				$post_object = get_sub_field('choose_pages');
    				$post_icon = get_sub_field('choose_icon');
    				if( $post_object ):
    					$post = $post_object;
    					setup_postdata( $post );
    					$i++; ?>
    					
    	<a href="/?chapter=<?php echo $i; ?>" id="link_<?php echo get_the_title( $p->ID ); ?>">
    		<i class="fa <?php echo $post_icon; ?> fa-2x"></i>
    		<span><?php echo get_the_title($post->ID); ?></span>
    	</a>
    					
    	<?php wp_reset_postdata();
    				endif;
    			endwhile;
    		endif; ?>
    					
    		<div class="clearfix"></div>
    					
    		<div class="nav2">
    						
    			<?php wp_nav_menu( array( 'theme_location' => 'user' ) ); ?>
    					
    		</div>
    				
    	</nav>

    And now everything is hunky dory again. SMH. Just shoot me now.

  • I love you. Thank you. So obvious. But yes, completely brain dead today.

  • I’ll have to keep working on this. Thank you! Question: How do I import a json file? the WordPress importer won’t let me do this for some reason 🙁 (note: this site doesn’t have the pro version of ACF)

  • I’m a novice at jQuery, I’m afraid. I’m trying to learn it, but it’s slow going for me.

  • Ahhhh…I seem to have gotten it to work now. Your help was invaluable. Thanks you!

    if( have_rows('home', 'option') ):
    
    while ( have_rows('home', 'option') ) : the_row();
    
    $post_object = get_sub_field('choose_pages');
    
    if( $post_object ):
    
    $post = $post_object;
    setup_postdata( $post ); ?>
    
    <article class="px-content" id="chapter<?php echo the_ID(); ?>">
    	<div class="px-inner">
    		<div class="container-fluid">
    			<div class="row">
    				<div class="headline">
    					<h1><?php echo get_the_title($post->ID); ?></h1>
    					<p>content</p>
    				</div>
    			</div>
    		</div>
    	</div>
    </article>
    				
    <?php wp_reset_postdata();
    	
    	endif;
    
    endwhile;
    
    endif;
Viewing 25 posts - 26 through 50 (of 86 total)