Search
 
SCRIPT & CODE EXAMPLE
 

PHP

get current post category id wordpress

global $wp_query;
$postcat = get_the_category( $wp_query->post->ID );
Comment

get category post in wordpress

echo '<p>'. get_the_category( $id )[0]->name .'</p>';
Comment

get_post by category in wordpress

<?php

                            $args = array('posts_per_page' => 10, 'offset' => 0, 'category' => 11);

                            $myposts = get_posts($args);
                            $count=1;
                            foreach ($myposts as $post) : setup_postdata($post); ?>
                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-6 col-xl-6">
                                    <div class="portfolio-list" data-aos="fade-up">
                                        <div class="portfolio-image">
                                            <h6>Case Study - <?php echo $count ?></h6>
                                            <div class="portfolio-detail-image">
                                                <img src="<?php the_post_thumbnail_url() ?>" class="img-fluid" alt="Olam Solutions">
                                            </div>
                                        </div>
                                        <div class="portfolio-content" data-aos="fade-up">
                                            <h3><a href="<?php the_permalink();  ?>"><?php the_title(); ?></a></h3>
                                            <p>Website Design & Development</p>
                                            <a href="<?php the_permalink();  ?>" class="view-case-btn">View Case <span class="icon-right-arrow"></span></a>
                                        </div>
                                    </div>
                                </div>
                            <?php
                            $count= $count+1;
                            endforeach;
                            wp_reset_postdata();

                            ?>
Comment

get category of current post wordpress

$active_categories = get_the_category();
Comment

PREVIOUS NEXT
Code Example
Php :: laravel get auth user in constructor 
Php :: php while loop of alphabet 
Php :: get today datetime in php 
Php :: migration status php 
Php :: remove first element in array php 
Php :: Laravel Auth Redirect based on role 
Php :: php check for empty string 
Php :: how to validate use unique in laravel 8 controller 
Php :: date format in laravel month name day name 
Php :: php session get data 
Php :: php set alternatives 
Php :: wordpress get post slug 
Php :: cache clear in laravel 
Php :: Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in 
Php :: toarray php 
Php :: 24 hours date format php 
Php :: how refresh object in database in laravel 
Php :: php contains substring 
Php :: get header respnse code php curl 
Php :: delete method laravel 
Php :: artisan commands in route 
Php :: composer update withou memory limit 
Php :: php convert mb to bytes 
Php :: php convert array to number 
Php :: php json_encode 
Php :: br php 
Php :: wordpress query multiple post ids 
Php :: laravel migration change column default 
Php :: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://vtl-lab.com/VN/crecc-cms/api/member/register.json. (Reason: CORS request did not succeed). 
Php :: convert array to string laravel 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =