Custom post type sortable columns when column value is from a custom database value

You can sort the results based on your custom table data by applying a custom filter to your existing query using the “posts_orderby” hook (untested example code): add_filter(‘posts_orderby’, ‘edit_posts_orderby’); function edit_posts_orderby($orderby_statement) { $orderby_statement = “views DESC”; return $orderby_statement; } Source: based on user comment at: https://developer.wordpress.org/reference/hooks/posts_orderby/

How to display custom taxonomy term specific post?

Refer Link for Your Knowledge Template Hiearchy for a more detailed break down of how WordPress chooses the template For a taxonomy term slug (‘sports’ your example) in the taxonomy (e.g. ‘News’) WordPress will try to use the following templates (in this order) taxonomy-{taxonomy}-{slug}.php taxonomy-{taxonomy}.php taxonomy.php archive.php index.php Modify Your texonomy Code snippet below : … Read more

Remove custom permalink base from CPT custom category and custom tags

via: https://cnpagency.com/blog/the-right-way-to-do-wordpress-custom-taxonomy-rewrites/ I needed to change the order of registering the taxonomy (make sure it’s before CPT) and the CPT (make sure it’s after registering any taxonomy). Now ‘rewrite’ => array( ‘slug’ => ‘resources/tags’, ‘with_front’ => false ), works as expected!