Modify WordPress v4.4 + header title

As we all know `wp_title()` is being deprecated as of WordPress 4.4. it is recommended that you instead use its replacement: [the title-tag theme](https://make.wordpress.org/core/2014/10/29/title-tags-in-4-1/) feature. Here’s the WordPress filter to modify the header initiated by `wp_get_document_title`. Replace whole title tag with pre_get_document_title filter: ~~~ add_filter( ‘pre_get_document_title’ , ‘render_title’ ); function render_title($title){ return ‘New title ‘; } ~~~ Or with `document_title_parts` get more creative. ~~~ add_filter( ‘document_title_parts’ , ‘render_title’ ); function render_title($parts){ $parts[“title”] = “My Prefix “. $parts[“title”]; return $parts; } ~~~ I would love to hear other improved ways to do this, hope it helps!

Create Custom Tags for Custom Post Types (WordPress)

If you need to create custom tags for custom post types, here’s what you need to do to add/allow “custom tags” to your custom post types in WordPress. These custom tags should only list your custom post type and not the other posts. Here are the steps. ###1. Register taxonomy And Post Type First you need to register taxonomy term for Post Tag. Edit your theme functions.php or plugin file to register taxonomy for custom tag like so. ~~~ //register taxonomy for custom post tags register_taxonomy( ‘custom-tag’, //taxonomy ‘my-custom-post’, //post-type array( ‘hierarchical’ => false, ‘label’ => __( ‘My Custom Tags’,’taxonomy general name’), ‘singular_name’ => __( ‘Tag’, ‘taxonomy general name’ ), ‘rewrite’ => true, ‘query_var’ => true )); ~~~ Then you need to register custom post type like this : ~~~ //register custom posts type $snippet_pt_args = array( ‘labels’ => array( ‘name’ => ‘Custom Posts’, ‘singular_name’ => ‘Custom’, ), ‘taxonomies’ => array(‘custom-tag’), ‘public’ => true, ‘menu_icon’ => ‘dashicons-groups’, ‘show_ui’ => true, ‘rewrite’ => array(‘slug’ => ‘custom-post-slug’, ‘with_front’ =>false, ‘menu_position’ => null), ‘label’ => ‘My Custom Posts’ ); register_post_type( ‘my-custom-post’, $snippet_pt_args); ~~~ So basically we can combine them and attach them to WordPress initialization hook` init` like so: ~~~ add_action(‘init’, ‘_question_register_post_type’); function _question_register_post_type(){ //register taxonomy for custom post tags register_taxonomy( ‘custom-tag’, //taxonomy ‘my-custom-post’, //post-type array( ‘hierarchical’ => false, ‘label’ => __( ‘Custom Tags’,’taxonomy general name’), ‘singular_name’ => __( ‘Tag’, ‘taxonomy general name’ ), ‘rewrite’ => true, ‘query_var’ => true )); //register custom posts type $snippet_pt_args = array( ‘labels’ => array( ‘name’ => ‘Custom Posts’, ‘singular_name’ => ‘Custom’, ), ‘taxonomies’ => array(‘custom-tag’), ‘public’ => true, ‘menu_icon’ => ‘dashicons-groups’, ‘show_ui’ => true, ‘rewrite’ => array(‘slug’ => ‘custom-post-slug’, ‘with_front’ =>false, ‘menu_position’ => null), ‘label’ => ‘My Custom Posts’ ); register_post_type( ‘my-custom-post’, $snippet_pt_args); } ~~~ Now go to WordPress admin dashboard and flush the rewrite rules by clicking “Save Changes” in “Permalink Settings”. You should now be able to add custom tags to your Custom post types. ###2. Retrieve Custom Post Types by their Tags After the creation of custom post types with their own custom tags, you can now list them on a custom template. Go to your theme directory and create a template called `taxonomy-{custom-tag}.php`. Replace “custom-tag” with your registered taxonomy term and also remove the brackets. ~~~ if(have_posts()){ while (have_posts()){ the_post(); echo ‘