How do you remove a Category-style (hierarchical) taxonomy metabox - wordpress

I was wondering if someone can help me with this. I'm currently following Shibashake's tutorial about creating custom meta-boxes that include taxonomy selection here: http://shibashake.com/wordpress-theme/wordpress-custom-taxonomy-input-panels .
They show how to remove the standard metabox Wordpress automatically creates for taxonomies using the remove_meta_box function. Only problem is that the function for some reason doesn't seem to work on taxonomies that work as categories ie ones where the hierarchical option is set to true. I know I have the function working because the ones set up as tags disappear easily enough. I can't if it just isn't possible or if there is something special I need to add in one of the parameters to make it work.
Example:
$args = array(
'hierarchical' => false,
'label' =>'People',
'query_var' => true,
'rewrite' => true
);
register_taxonomy('people', 'post',$args);
remove_meta_box('tagsdiv-people','post','side');
That works fine. If I set hierarchical to 'true, however, the meta box stays put.
Can anyone shed some light?

Found the answer asking over at the Wordpress side of StackExchange:
For taxonomies that work like tags, you use "tagsdiv-slug". But for ones that are hierarchical, you use "slugdiv". The answe can be found here:
Thanks to #Jan Fabry for his answer

Related

WordPress archive/taxonomy location

I'm struggling with this, despite being okay at WordPress dev.
I've created a custom post type called links
I've also created a custom taxonomy called link-type
All works fine when using archive.php in the root of the theme.
However I want links to be a child page of resources so:
example.com/links/ would become example.com/resources/links/
And clicking on a taxonomy term link for example downloads would take you to example.com/resources/links/downloads/
I'm aware of has_archive and rewrite and with_front and slug but can't understand how to use these to achieve the aforementioned structure.
As always, expert help is much appreciated.
When you register your post type, just add whatever you want to the slug in the rewrite argument, forward slashes are acceptable in slugs.
$args = array(
'labels' => $labels,
...
'rewrite' => array(
'slug' => 'resources/links',
'with_front' => true
),
);
This will give you https://example.com/resources/links/, even if you have a page already at https://example.com/resources/.
I almost forgot, you'll need to make sure your flush your rewrite rules (this can be done programatically when the CPT is registered, or you can just go to your Settings > Permalinks option page and click Save Changes to accomplish the same thing one time.

Custom Post Types with Parent Pages - best practice

I am working on a site with product categories and individual products organized like this:
product category 1
product
product
product
product category 2
product
etc...
It was suggested to me that the best way to do organize the individual products was to create a custom post type for products. The product categories are currently pages.
So now I am trying to figure out the best way to connect a product custom post type with its particular product category page (so that url structure can be "/product_category/product/").
I am sure there is a smart and efficient way to do this, but I'm not seeing it. I was thinking that I could add categories to the pages and CPT's - but that isn't quite the effect that I want because I don't want them to only be accessible as archive pages. Is that actually a problem?
Sorry that this is such a broad question - I can get it to work but am sure that my first try would not be the best way, so I am just looking for some pointers or examples from people who have done this before to steer me in the right direction.
Thanks in advance, any help appreciated.
You can use Custom Taxonomies.
function product_categories_init() {
register_taxonomy(
'product-category',
'product', // Or 'post', whatever the custom post type is
array(
'label' => __( 'Product Categories' ),
'rewrite' => array( 'slug' => 'product-categories' ),
'hierarchical' => false,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
)
);
}
add_action( 'init', 'product_categories_init' );
This is a simple example. You'll have to check out the options in the reference link. But it is essentially your own kind of category for a post type (or an array of post types).
In the end I did get this right. Part of my problem was due to a misunderstanding about how to use categories in wordpress.
What I ended up doing was use the custom taxonomy as shown by Austin Winstanely's answer, and then refactor my page organization a little bit so that the product category was not a page post type, but a category - displayed using the category template. This makes it very convenient, because individual products in the custom post type can be associated with their product category very easily. When I asked the question I had not understood that categories could have their own template and function as web pages.
Thanks for the help!
-Alyssa

Disabling some buttons from wp_editor

I use tinyMce editor in meta boxes of Wordpress by the following line of code, I want to remove some buttons when I use there. I don't want to affect the main editor. I know how to remove some buttons, which is told here.
My question is, is it possible to disable some buttons (e.g. more) when I call editor with wp_editor. I checked its manual, arguments doesn't seem to support this.
wp_editor( $careers_settings["description"], "editor", array("media_buttons"=>FALSE, "textarea_name"=>"description", "textarea_rows"=>5) );
Thank you.
I guess it's a bit late to answer but in case it might be useful for someone. Since Tinymce 4, "toolbar1" must be used and "teeny" must be set as false to modify buttons :
wp_editor(
'id',
'value',
array(
'teeny'=>false,
'media_buttons'=>false,
'tinymce' => array(
'toolbar1' => 'bold, italic, underline,|,fontsizeselect',
'toolbar2'=>false
),
)
);
Also I added "toolbar2" to the array. I realized that although I only set toolbar1, additional buttons still appear in some cases. Setting toolbar2 as false will remove default buttons on the second buttons row.
You should check the referenced manual again - it's possible to have tinymce as parameter and pass an array of configuration options, e.g. like
wp_editor($value, "input...", array(
'tinymce' => array( .. //tinymce configuration options here )
))
Haven't tried it out, but it should work like that.

Change Permalink of content type

I have a wordpress that has several different content types. I have a spanish version of the site, and in some cases I need to change the permalink structure to match the language.
For example, one content type is a product. Currently the permalink structure is as follows:
http://www.example.com/product/product-name/
however I would need to make it:
http://www.example.com/productos/product-name/
I tried to set it in the initial "register_post_type" method under "rewrite". It didn't seem to do anything.
How can I make this change?
Thanks,
Dan
Try specifically setting the "slug" value under "rewrite":
'rewrite' => array( 'slug' => 'productos' )
If it still doesn't work, make sure to flush your WP cache if you have one activated.

Adding custom taxonomy to media gallery in wordpress admin

I have added a custom taxonomy to Media, which is showing up as a text field in the Media admin section. I would like this to be the typical checkbox format as it exists in the custom post type admin page. Is there a way to override this in the functions to make this custom taxonomy show in checkboxes, so the user could easily choose which image belongs to a specific taxonomy entry?
Here is the code I used to bring the taxonomy into the Media Gallery:
register_taxonomy('Categories',array('project', 'slides', 'attachment'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'categories' ),
));
In the first line, by adding 'attachment' to the array, it added the Project Categories field in the Media Gallery. Now I just need to make this a list of checkboxes containing the current taxonomy entries. Any thoughts on how to achieve this?
I found this article, but having never used filters, it was a bit perplexing as to how to make this work for me:
https://wordpress.stackexchange.com/questions/29858/adding-category-tag-taxonomy-support-to-images-media
You are most of the way there. To render a taxonomy category as a special HTML display, like a list of checkboxes, the best method is to use the built-in WordPress Walker class. It is made exactly for this sort of thing.
http://codex.wordpress.org/Function_Reference/Walker_Class
I use this very method to create a new "SLP_Tagalong" walker class that renders a list of my taxonomy categories as a list of checkboxes (I only show text names but it could easily show the marker images) whenever anyone edits a store location.
I have the modified Walker Class I can share if you would like to see it. I'd post here but it is 150 lines. Send me a PM and I'll shoot it back that way.
I am sure the walker class would have worked successfully, but looking at the codex reminded me of string theory and existentialism. The upside is with WP 3.5.1, when you associate a taxonomy to 'attachment' set to Hierarchal, the checkbox appears in the Media Library by default.
YAY!!
This may not answer the question posed thoroughly though so I will leave it open for anyone who wants to stab at this.

Resources