Loop Through Categories in Custom Field

The way you’re appending a foreach loop to a variable is not possible. Try this: $form_fields[“custom4”][“html”] = “<select name=”attachments[{$post->ID}][custom4]” id=’attachments[{$post->ID}][custom4]’>”; foreach ($categories as $category) { $form_fields[“custom4”][“html”] .= ‘<option value=”$category”>’ . $category . ‘</option>’; } $form_fields[“custom4”][“html”] .= “</select>”;

Help with SQL query, how to add taxonomie terms with value stored in options?

ok folks, i did it anothere way.. here’s how i did it: add_filter( ‘pre_get_posts’, function( $query ) { if( ! is_main_query() || ! is_post_type_archive() || ! $query->get( ‘section’, false ) ) return $query; global $wpdb; $section = $query->get( ‘section’ ); unset( $query->query[‘section’] ); unset( $query->query_vars[‘section’] ); $query->tax_query = false; $query->set( ‘tax_query’, false ); $cateroties = … Read more

Category Template for Custom Post Type

You should create a taxonomy template, not a category. I suspect that you have misunderstanding about categories, terms and custom taxonomies. I would suggest that you read my post on this particular subject here Study the taxonomy template hierarchy in the linked page in your question As for the 404 page, you most probably haven’t … Read more

How to remove specific categories from tag archives?

One way to do this would be to create a custom widget which displays categories using wp_list_categories(). Then exclude any categories you don’t want displayed using the exclude option of wp_list_categories(): http://codex.wordpress.org/Template_Tags/wp_list_categories#Include_or_Exclude_Categories. This example below creates a custom categories widget in Appearance / Widgets. This code can be added to functions.php or used in a … Read more

get parent_category class in loop

First you would need to check if the category has children, if it does then we can show a few things. Below is a helpful function to check just that. function category_has_children( $term_id = 0, $post_type=”post”, $taxonomy = ‘category’ ) { $children = get_categories( array( ‘child_of’ => $term_id, ‘type’ => $post_type, ‘taxonomy’ => $taxonomy ) … Read more