How to get a custom taxonomy slug in body classes

To add the custom taxonomy slug to the body classes of your WordPress site, you can use the body_class filter along with your custom code. Below is your example of how you can achieve this: function themeprefix_add_taxonomy_class($classes) { global $post; if (is_page()) { $taxonomy = ‘page_section’; $terms = get_the_terms($post->ID, $taxonomy); if ($terms && !is_wp_error($terms)) { … Read more

Right Permalink for Custom Post Type with number slug

You need to write a rewrite URL for the galley, please see the below code and paste into your active theme functions.php file function gallery_custom_rewrite_rule() { add_rewrite_tag(‘%gallery_id%’, ‘([^&]+)’); // Rule to handle numeric slugs in a gallery post type add_rewrite_rule( ‘^gallery/(.+)/([0-9]+)/?$’, ‘index.php?post_type=gallery&gallery_id=$matches[2]’, ‘top’ ); } add_action(‘init’, ‘gallery_custom_rewrite_rule’, 10, 0); function gallery_query_vars($query_vars) { $query_vars[] = ‘gallery_id’; … Read more

category id (term_id) in url instead of slug

Try this. Here is the full code that you can add to your functions.php file: // Add custom rewrite rules function add_custom_rewrite_rules() { add_rewrite_rule( ‘^category/([0-9]+)/?$’, ‘index.php?term_id=$matches[1]’, ‘top’ ); flush_rewrite_rules(false); // Temporarily set this to true to flush rules, then set back to false } add_action(‘init’, ‘add_custom_rewrite_rules’); // Add term_id to query vars function add_query_vars($vars) { … Read more

Show category name in category.php when posts assigned to multiple categories

For the heading on a category archive use either: the_archive_title(); Or: single_term_title(); The first one can be used on the template for any archive, while the second should only be used on category, tag, or taxonomy archive templates. You shouldn’t need to get anything from any of the individual posts. They may have other categories … Read more

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