Original Author URI: https://burobjorn.nl ******************************************************************************/ /* Copyright 2012 Tag Pages is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Tag Pages is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** * Add the 'post_tag' taxonomy, which is the name of the existing taxonomy * used for tags to the Post type page. Normally in WordPress Pages cannot * be tagged, but this let's WordPress treat Pages just like Posts * and enables the tags metabox so you can add tags to a Page. * NB: This uses the register_taxonomy_for_object_type() function which is only * in WordPress 3 and higher! */ // add tag and category support to pages if( ! function_exists ('hangar_category_tags_support_all') ){ function hangar_category_tags_support_all() { register_taxonomy_for_object_type('post_tag', 'page'); register_taxonomy_for_object_type('category', 'page'); } add_action('init', 'hangar_category_tags_support_all'); } // ensure all pages are included in tag and category queries if( ! function_exists ('hangar_category_tags_support_query') ){ function hangar_category_tags_support_query($wp_query) { if ($wp_query->get('tag')) $wp_query->set('post_type', 'any'); if ($wp_query->get('category')) $wp_query->set('post_type', 'any'); } add_action('pre_get_posts', 'hangar_category_tags_support_query'); } /** * Display all post_types on the tags archive page. This forces WordPress to * show tagged Pages together with tagged Posts. Thanks to Page Tagger by * Ramesh Nair: http://wordpress.org/extend/plugins/page-tagger/ */ if( ! function_exists('hangar_tagpages_display_tagged_pages_archive') ){ function hangar_tagpages_display_tagged_pages_archive(&$query) { if ( !is_admin() && $query->is_archive && $query->is_tag ) { $q = &$query->query_vars; $q['post_type'] = 'any'; } } add_action('pre_get_posts', 'hangar_tagpages_display_tagged_pages_archive'); } // show category using shortcode // https://stackoverflow.com/a/13996873 if( ! function_exists('hangar_show_categoriced') ){ function hangar_show_categoriced() { add_shortcode('hangar-catlist', function($atts, $content) { $atts += array('category' => 1); $posts = get_posts("category={$atts['category']}"); foreach ($posts as $post) { echo $post->post_name . '
'; } }); //echo do_shortcode('[hangar-catlist category=5]'); } } if( ! function_exists('hangar_show_tagged') ){ function hangar_show_tagged() { add_shortcode('hangar-taglist', function($atts, $content) { $atts += array('tag' => 1); $posts = get_posts("tag={$atts['tag']}"); foreach ($posts as $post) { echo $post->post_name . '
'; } }); //echo do_shortcode('[hangar-taglist tag=5]'); } }