Add all category as classes in foreach loop

Please replace: $new->category_slug = wp_get_post_terms($post->ID, ‘portfolio_category’)[0]->slug; with $category_slug = wp_get_post_terms($post->ID, ‘portfolio_category’); $cat_cls=””; foreach($category_slug as $cat_classes){ $cat_cls .= ” ” . $cat_classes->slug; } $new->category_slug = $cat_cls; Because the code you have written above will store only first category it will get.

Only Show Excerpt After First 3 Posts

You could add a count variable and count how many times the page has looped and only show the excerpt if the count is 3 or greater.: <?php $Count = 0; ?> <div class=”content-block-archive”> <div class=”content-block-archive-thumbnail”> <a href=”https://wordpress.stackexchange.com/questions/343700/<?php the_permalink(); ?>”><?php echo get_the_post_thumbnail($post_id, ‘large’, array(‘class’ => ‘alignleft’)); ?></a> </div> <div class=”content-block-archive-meta”> <h2 class=”content-block-archive-title”><a href=”https://wordpress.stackexchange.com/questions/343700/<?php the_permalink(); ?>”><?php … Read more

Add Search and Filter functionality to custom loop

You must create a different search form for your post type, so that search results can be displayed according to post type. You can add this to your search form <input type=”hidden” name=”post_type” value=”meetup_groups”> Example : <form method=”get” id=”my-custom-searchform” action=”<?php echo esc_url(home_url( “https://wordpress.stackexchange.com/” )); ?>”> <input type=”text” value=”<?php the_search_query(); ?>” name=”s” id=”s” placeholder=”<?php echo esc_attr__( … Read more

How to separate post titles with a comma in the loop?

Instead of outputting everything immediately, save it to a variable so you can conditionally add a comma (and presumably a space) between items: <?php // The Loop if ( $query->have_posts() ) { // Save the number of posts found global $wp_query; $total_posts = $wp_query->post_count; // Set a counter variable $i=0; while ( $query->have_posts() ) { … Read more

How to use single.php output in function.php

I don’t undesrtand well what you want to do. You mean this??? (the last line): <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( ‘content’, get_post_format() ); ?> $content = get_the_content(); $content = apply_filters(‘the_content’, $content); echo wp_strip_all_tags($content); $Temp_text=wp_strip_all_tags($content); do_something($Temp_text); ?> And implement do_something() inside functions.php

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)