Adding a tag_ID column into Categories inside the admin dashboard?

You can do it like so: Use the manage_<screen ID>_columns filter to add the “ID” column. Example for the default category taxonomy where <screen ID> is edit-category — for other taxonomies, it would be edit-<taxonomy> like edit-post_tag: add_filter( ‘manage_edit-category_columns’, ‘my_manage_edit_category_columns’ ); function my_manage_edit_category_columns( $columns ) { // Add the “ID” column. $columns[‘term_id’] = ‘ID’; // … Read more

Why does the post_type_link hook everything twice?

When you add a filter to post_type_link, you are telling WordPress to run the hooked function on the result of the get_post_permalink() function. So any time that function runs, so does yours. When I tested the filter myself, I only saw a printed message once for each link, but if you have something like this: … Read more

How to say if meta_value is greater than 0 in an array?

As documented, you can use meta_compare: $args = array( ‘meta_key’ => ‘userfunds’, ‘meta_value_num’ => ‘0’, ‘meta_compare’ => ‘>’, ); Note that I changed meta_value to meta_value_num. This ensures the values is treated as a number for the comparison. You’d probably be ok without it, but it doesn’t hurt.

Get the last 5 products from each category

You have to ways to achieve this I guess. The one that you pick depends on how many products and how many categories are present in your website. If you have an huge amount of products but not so many categories, then probably the best approach is to get the categories first: $product_categories = get_terms( … Read more

Custom meta box values are not getting saved for my custom post type

but remaining values (checkbox, select, images) are not getting saved I believe those fields are also getting saved, but you are just not displaying them correctly. And you should always escape input/textarea values, e.g. use esc_attr() for single-line inputs and esc_textarea() for textareas (multi-line inputs). So to make your code work correctly, try these: First … Read more

Header not properly displaying on archive.php

You forgot to add get_header() , please try below code. <?php get_header(); ?> <div class=”container”> <h1><?php single_cat_title();?></h1> <?php if (have_posts()) : while(have_posts()) : the_post();?> <div class=”card mb-4″> <div class=”card-body”> <?php if (has_post_thumbnail()):?> <img src=”<?php the_post_thumbnail_url(‘smallest’);?>” class=”img-fluid”> <?php endif;?> <h3><?php the_title();?></h3> <?php the_excerpt();?> <a href=”<?php the_permalink();?>” class=”btn btn-success”>Read more</a> </div> </div> <?php endwhile; endif;?> </div> <?php … Read more

Return product description

If you want to get the product description instead of product terms descriptions you can do this. protected function GetDescription ($ProductID) { return get_post_field(‘post_content’, $ProductID); } This will return the content field by the id, if no content exists it will return an empty string.