• Hello, this get_the_tags() makes me crazy ??
    I have the following php with loops:

    <div id="filter-blog-isotope" class="portfolio-filter">
                                <div id="count-projects"><!--<i class="font-icon-forward">--></i><span class="current-number">00</span><!--<span class="num-name"> / Related Information</span>--></div>
                                <ul>
                                    <li><a href="#" class="has-items selected" data-filter="*">All</a></li>                         
    
                                    <?php
    
    									//Define the loop based on arguments
                                        $loop = new WP_Query( $args );
    
                                        //Display the contents
                                        while ( $loop->have_posts() ) : $loop->the_post();   	
    
                                    ?>                         
    
                                    <li><a href="#" data-filter=".<?php
    															  $posttags = get_the_tags();
    															  if ($posttags) {
    																foreach($posttags as $tag) {
    																  echo $tag->slug;
    																}
    															  }
    														  ?>"><?php
    															  $posttags = get_the_tags();
    															  if ($posttags) {
    																foreach($posttags as $tag) {
    																  echo $tag->slug;
    																}
    															  }
    														  ?></a></li>                                   
    
                                	<?php endwhile;?>
    
                                </ul>
                            </div>                                  	
    
                            <div id="blog" class="wide">
    							<div id="blog-posts-container" class="normal-blog-pagination">
    
    								<?php
    
                                        //Define the loop based on arguments
                                        $loop = new WP_Query( $args );               
    
                                        //Display the contents
                                        while ( $loop->have_posts() ) : $loop->the_post();
    
                                        $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
    
                                    ?>                         
    
                                    <article class="item-blog <?php
    															  $posttags = get_the_tags();
    															  if ($posttags) {
    																foreach($posttags as $tag) {
    																  echo $tag->slug;
    																}
    															  }
    														  ?>">
    
                                        <div class="post-container">
    
                                            <div class="post-creative post-image" style="background-image: url(<?php echo $url; ?>);">
                                                <a class="post-link" title="<?php the_title(); ?>" target="_blank" href="<?php the_permalink(); ?>">
                                                    <div class="post-caption">
                                                        <div class="post-naming">
                                                            <h2 class="post-title"><?php the_title(); ?></h2>
                                                            <span class="post-date"><?php the_content(); ?></span>
                                                        </div>
                                                    </div>
                                                </a>
                                            </div>
                                        </div>
                                    </article>                                   
    
                                	<?php endwhile;?> 
    
                                </div>
    
                            </div>

    trying to display a sortable article list. Works well except that the classes for my articles are retrieved (as expected) from the tags in each post but only for the first 3 posts (maybe because there are for now 3 tags defined). I have to have for the isotope li data-filter form the tags (which seems to work perfecter the first) and classes for the articles in reference to them. What am I doing wrong here?
    Thanks so much for help!
    Garavani

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Garavani

    (@garavani)

    How can I post php code that parts of will not be hidden from display? Weird!

    EDIT: Sorry, I see it only has shifted to the right. Strange yet.

    which code using get_the_tags() creates the problem? (seems to be used three times in the code…)

    does each post have just one tag?

    you don’t seem to be outputting spaces between the tags if there is more than one tag in a post.

    can you post a link to your site to illustrate the output of your code?

    Thread Starter Garavani

    (@garavani)

    Hi Michael!

    First of all so many thanks for your reply!

    1) Yes there will be only one tag in the concerning posts. (a year i.g. 2012 = number)

    2) Yes, the same code is used twice because the theme uses a filter isotope js and needs a data-filter for the li list and a respective (additional to the one “item-blog)” class for each post. Perhaps this is not very elegant I didn’t know how to do better.

    3) Sadly I cannot put any link because it is client project and client does not want anybody to see the page for now.

    Thanks again!

    can you post the html as created as a result by the template?

    are any after post number three empty or wrong?

    Thread Starter Garavani

    (@garavani)

    Hi Michael,

    you are up so early on Saturday morning?

    In this moment I wanted to post here that eventually all this has to do with my Custom Post Type (CPT UI) plugin and the customized post types I built!

    It seems that I forgot somehow to access them correctly.
    I experimented on another place with tags and it did work!

    So it’s all my fault, I am so sorry having wasted your time! ??
    I am now trying to figure this out how I can access in php my customized “tag” taxonomy!

    Thanks again so much and SORRY!

    time is never wasted …

    you are up so early on Saturday morning?

    this is still very late Friday night for me – I am actually on a different side of the world ??

    Thread Starter Garavani

    (@garavani)

    Cool! Thank you very much! Have a nice weekend where ever you are!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘problem with get_the_tags()’ is closed to new replies.