Categories’ hierarchy in URL

The permastruct /%category%/%postname%/ will include the categories and subcategories in the URL from top to first assigned child. So, if you want the URL be site.com/source/books/moby-dick/*postname*, you have to assign the post only to “Moby Dick”. Assigning the post only to “Moby Dick” category will still show the post under “source” and “books” category archives … Read more

Disable block from editor based on post type

You can use the allowed_block_types hook: <?php function wpse_allowed_block_types($allowed_block_types, $post) { // Limit blocks in ‘post’ post type if($post->post_type == ‘post’) { // Return an array containing the allowed block types return array( ‘core/paragraph’, ‘core/heading’ ); } // Limit blocks in ‘page’ post type elseif($post->post_type == ‘page’) { return array( ‘core/list’ ); } // Allow … Read more

How to enable hierarchical permalinks for hierarchical taxonomies

This is implemented in WordPress now as of 3.1. When you register your taxonomy, make sure to set rewrite hierarchical to true as well as the taxonomy itself: <?php register_taxonomy(‘genre’,array(‘book’), array( ‘hierarchical’ => true, // this makes it hierarchical in the UI ‘labels’ => $labels, ‘show_ui’ => true, ‘query_var’ => true, ‘rewrite’ => array( ‘hierarchical’ … Read more

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