Wordpress Tags in class

I have added tags to my Custom Post Type. Now I want to use them to create a isotope portfolio, I can load all tags with this code:

<?php $args = array( 'post_type' => 'portfolio', 'posts_per_page' => 24;
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
    <div class="all <?php echo $tag->slug; ?>">
        <?php echo the_post_thumbnail(); ?>
        <p><?php the_title(); ?></p>
    </div>
<?php endwhile; ?>

But now I want to add the all tags that from each portfolio item to the class="". With <div class="<?php $tag->slug; ?>"> I just get the last tag of all the tags that are used.

I know there are already a lot of posts about this problem, but every post I have found does not seem to work for me.

Solutions

It now works with the following code:

<?php $tags = get_the_tags();
    $tag = wp_list_pluck( $tags, 'slug' );
    $tagToClass = implode(" ", $tag);
?>

And then use <?php echo $tagToClass ?>

Tags: Wordpress / Class / Loops

Similar questions

Synchronize Custom post type tags to WordPress default posts tags
I am new with WordPress plugin development. I have to Synchronize custom post type tags with WordPress default post type tags. So when user will create, delete or update any custom post type tag it should be updated in Default tags. I do not have enough knowledge with WordPress hooks so if someone guide me about this that will be appreciated. This ...
Synchronize custom post type tags with WordPress default post type tags
I am not very experienced developer and i have to solve one issue. My client wants to synchronize Ultimate member plugin tags (custom post type tags) with WordPress default posts tags. Actually ultimate member plugin tags and default posts tags will be same and he do not want to create these again. So he wants to use same taxonomy for both of these...
Differentiating between P tags wrapping images and P tags wrapping text nodes in Wordpress?
I need a good solution to be able to style <p> tags differently in a wordpress post. More specifically I need to differentiate between paragraphs and images. Wordpress just wraps all new lines in <P> tags. Here are some possibilities: I do not want blog contributors to have to do something manually (add div tags), I want this done in th...
wordpress backend: retrict post tags to site tags only
In the post screen, I want to remove the option of multi-authors being able to 'free tag' their posts. In other words, only allow tags that have been preset in the admin tags section.(these tags are of course visible in the tag cloud in posts screen) The concept is to prevent authors introducing random tags in their posts, leading to duplication an...
WordPress allow PHP tags in html editor - surrounding html tags with if else statement
I have searched for hours and I can't make this work. The plugin is supposed to let you type [php] and [/php] tags surrounding your php code which allows it to function in a tinymce html editor. It works properly like this: But doesn't work when I try to break up the code and surround html: I'm trying to accomplish doing an if/else statement inside...
Select certain tags to display instead of all tags in WordPress
In WordPress I am display all the tags by using this function This then prints out all the tags. Instead of display all tags is there a way I can say which tags I wish for it to display the slug and link to? I have also tried this I am sure the answer is on this page but I can not come up with the solution http://codex.wordpress.org/Function_Refere...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.