Support

Account

Forum Replies Created

  • Hah, well that’s simple enough – never enqueue’d in any other file other than functions. Thanks 😛

  • @hube2 so I have a really silly question to your answer… How are you enqueuing the script inside the loop itself?

    I’m actually trying to do this same thing. Drupal is nice in that I can attach libraries in any template I want and if I can figure out the same for WordPress that would be fantastic!

  • Hey @jonas, $get_image = wp_get_attachment_image_src ( $attachment_id, 'thumbnail' ); doesn’t seem to be returning anything for me, any ideas? ($icon, $mime, and $attachment_id are all returning correct data)

  • I’m having the same problem as @adejones … got anymore info?

  • So this thread has been very helpful! The answer @meandhim provided works great on all my pages, but I am unable to get this to work on my set Posts page – I am only assuming because it is having an issue w/ get_the_ID

    Here is what i’ve got:

    <?php
      $ad_args = array(
        'post_type'       => 'ad',
        'posts_per_page'  => -1,
        'orderby'         => 'rand',
        'meta_query'      => array(
          array(
            'key'     => 'ad_connected_pages',
            'value'   => '"' . get_the_ID() . '"',
            'compare' => 'LIKE'
          )
        )
      );
    
    // query
    $ad_query = new WP_Query($ad_args);
    ?>
    
    <?php if( $ad_query->have_posts() ): ?>
    	<ul>
    	<?php while( $ad_query->have_posts() ) : $ad_query->the_post(); ?>
    		<li>
    			<a href="<?php the_field("ad_url"); ?>">
            <?php $adIMG = get_field("ad_image"); ?>
    				<img src="<?php echo $adIMG['url']; ?>" />
    			</a>
    		</li>
    	<?php endwhile; ?>
    	</ul>
    <?php endif; ?>
    
    <?php wp_reset_query(); ?>
    
  • Solved my own problem:

    <?php
    /*
      Template Name: Assets Template
    */
    get_header(); ?>
    
              <h1><?php echo get_the_title(); ?></h1>
    
              <hr>
    
              <!-- Start the Loop. -->
              <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
                <div class="controls">
                  <?php
                    $terms = get_terms( 'asset-categories', array('hide_empty' => false) );
                    $filter_links = array();
                    foreach ( $terms as $term ) {
                      $filter_links[] = '<button class="filter" data-filter=".'.$term->name.'">'.$term->name.'</button>';
                    }
                    $on_filter = join( "", $filter_links );
                  ?>
                  <label>Filters: </label><button class="filter" data-filter="all">All</button><?php echo $on_filter; ?>
    
                </div><!-- end .controls -->
                <div class="clear"></div>
    
                <div id="downloads-container">
                  <div class="container">
    
                    <?php
                      $rows = get_field('asset');
     
                      if($rows) {
     
                        foreach($rows as $key => $row) {
                          $column_id[$key] = $row['id'];
                        }
                        array_multisort($column_id, SORT_ASC, $rows);
     
                        $i = 0;
                        foreach($rows as $row) {
                            $taxonomyterm="";
                            for($i = 0; $i < count($row['category']); $i++) {
                                    $taxonomyterm = $taxonomyterm . $row['category'][$i] -> name . ' ';
                            }
                          echo '<div class="mix img ' . $taxonomyterm . '">' . (($row['image'])?) . '<img src="' . $row['image'] . '"/><h4>' . $row['name'] . '</h4>' . $row['description'] . '<div class="overlay"><a href="' . $row['file'] . '" class="expand" download>↓</a><a class="close-verlay hidden">x</a></div></div>';
                          $i++;
                        }
                      }
                    ?>
                  </div>
                  <div class="gap"></div>
                  <div class="gap"></div>
                </div>
    
                <?php endwhile; else : ?>
    
                  <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
    
              <?php endif; ?>
    
    <?php get_footer(); ?>
  • I think you and I are trying to do the same thing.
    I’ve created a taxonomy called “category” inside of my repeater “asset”, and now i’m trying to retrieve all the names selected from that taxonomy. (I’m also sorting them in ASC order…)

    Example of what I’m doing:

    <?php
                      $rows = get_field('asset');
     
                      if($rows) {
     
                        foreach($rows as $key => $row) {
                          $column_id[$key] = $row['id'];
                        }
                        array_multisort($column_id, SORT_ASC, $rows);
     
                        $i = 0;
                        foreach($rows as $row) {
                            $taxonomyterm="";
                            for($i = 0; $i < count($row['category']); $i++) {
                                    $taxonomyterm = $taxonomyterm . $row['category'][$i] -> name . ' ';
                            }
                          echo '<div class="mix img ' . $taxonomyterm . '"><img src="' . $row['image'] . '"/><h4>' . $row['name'] . '</h4>' . $row['description'] . '<div class="overlay"><a href="' . $row['file'] . '" class="expand" download>↓</a><a class="close-verlay hidden">x</a></div></div>';
                          $i++;
     
     
                        }
                      }
                    ?>

    Try this:

    <?php
                    $rows = get_field('explicit_component');
     
                      if($rows) {
     
                        $i = 0;
                        foreach($rows as $row) {
                            $taxonomyterm="";
                            for($i = 0; $i < count($row['explicit_component_type']); $i++) {
                                    $taxonomyterm = $taxonomyterm . $row['explicit_component_type'][$i] -> name . ' ';
                            }
    
                          echo '<div id="commitments"><h3>' . $taxonomyterm . '</h3>' . $row['explicit_component_text'] . '</div>';
                          $i++;
     
     
                        }
                      }
                  ?>
  • Check out the “Basic Display” section for ACF Taxonomy fields:
    http://www.advancedcustomfields.com/resources/taxonomy/

    <?php 
    
    $terms = get_field('explicit_component');
    
    if( $terms ): ?>
    
    	<?php foreach( $terms as $term ): ?>
    
    		<div id="commitments">
    			<h3><?php echo $terms['explicit_component_type'][0] -> name; ?></h3>
    			<p><?php echo $terms['explicit_component_text']; ?></p>
    		</div>
    
    	<?php endforeach; ?>
    
    <?php endif; ?>
Viewing 8 posts - 1 through 8 (of 8 total)