Get id of category from drop down menu

You’re on the right track with using a form, the only thing you’re missing, you have to submit what you have selected. For example like this: <form method=”GET” action=””> <div> <?php $select = wp_dropdown_categories(‘show_option_none=Select category&orderby=name&echo=0’); $select = preg_replace(“#<select([^>]*)>#”, “<select$1 onchange=”return this.form.submit()”>”, $select); echo $select; ?> <noscript> <div> <input type=”submit” value=”View” /> </div> </noscript> </div> </form> … Read more

How to display parent category name and link for custom breadcrumb

You can use get_ancestors: <?php if ( $term_ids = get_ancestors( get_queried_object_id(), ‘category’, ‘taxonomy’ ) ) { $crumbs = []; foreach ( $term_ids as $term_id ) { $term = get_term( $term_id, ‘category’ ); if ( $term && ! is_wp_error( $term ) ) { $crumbs[] = sprintf( ‘<a href=”https://wordpress.stackexchange.com/questions/225528/%s”>%s</a>’, esc_url( get_term_link( $term ) ), esc_html( $term->name ) … Read more

strip last comma from get_the_category

There are two ways to solve this issue. You need a clean array of category names for both, so let’s start with that: $cat_names = wp_list_pluck( get_the_category(), ‘cat_name’); $cat_names is now an array with just the names: Array ( [0] => aciform [1] => Cat A [2] => Cat B [3] => Cat C [4] … Read more

How to: 301 Redirect /category/ to /customname/

Htaccess is your friend in this case. You can create 301 form your old category base to the new like so: RewriteEngine on RewriteBase / RewriteRule ^old_dir/(.*) http://www.example.com/new_dir/$1 [R=301,L] Change old_dir to category example.com to your domain and new_dir to your custom name. Hope this helps. Ohad.

Hide a certain category name without removing it?

To achieve this we need to use get_the_category here. I am going to use this code in several places, so it is more efficient to create a function function exclude_cats($excludedcats = array()){ $categories = get_the_category(); $separator=”, “; $output=””; foreach($categories as $category) { if ( !in_array($category->cat_ID, $excludedcats) ) { $output .= ‘term_id ).'” title=”‘ . esc_attr( … Read more

Display one category in one page

From what I understand, the question is, how can you show only one category on a WordPress Page? What Scuba Kay is suggesting is the default category archive, if you want to go that route, WordPress already has archive pages with your posts for each category without you having to create your own Page. If … Read more

Changing the category permalink structure

The following code changes all links to category archives so they don’t include the parent category: add_filter( ‘category_link’, ‘wpse7807_category_link’, 10, 2 ); function wpse7807_category_link( $catlink, $category_id ) { global $wp_rewrite; $catlink = $wp_rewrite->get_category_permastruct(); if ( empty( $catlink ) ) { $catlink = home_url(‘?cat=” . $category_id); } else { $category = &get_category( $category_id ); $category_nicename = … Read more

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