Post Tags and Categories for Pages - Version 1.0

Version Description

  • relesed on WordPress repository
Download this release

Release Info

Developer curtismchale
Plugin Icon wp plugin Post Tags and Categories for Pages
Version 1.0
Comparing to
See all releases

Version 1.0

Files changed (2) hide show
  1. post-tag.php +98 -0
  2. readme.txt +28 -0
post-tag.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Post Tags and Categories for Pages
4
+ Plugin URI: http://wpthemetutorial.com/plugins/post-tags-and-categories-for-pages/
5
+ Description: Simply adds the stock Categories and Post Tags to your Pages.
6
+ Version: 1.0
7
+ Author: WP Theme Tutorial
8
+ Author URI: http://wpthemetutotial.com/about/
9
+ License: GNU General Public License v2.0
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+ */
12
+
13
+ /**
14
+ * todo give user the option to add categories and tags - on by default
15
+ * todo give user option to display tags and categories on archive pages - on by default
16
+ * TODO add categories to the end of pages
17
+ * TODO add the tags to the end of pages
18
+ */
19
+
20
+ /**
21
+ * Registers the taxonomy terms for the post type
22
+ *
23
+ * @since 1.0
24
+ *
25
+ * @uses register_taxonomy_for_object_type
26
+ */
27
+ function ptcfp_taxonomies_for_pages() {
28
+ register_taxonomy_for_object_type( 'post_tag', 'page' );
29
+ register_taxonomy_for_object_type( 'category', 'page' );
30
+ }
31
+ add_action( 'init', 'ptcfp_taxonomies_for_pages' );
32
+
33
+ /**
34
+ * Includes the tags in archive pages
35
+ *
36
+ * Modifies the query object to include pages
37
+ * as well as posts in the items to be returned
38
+ * on archive pages
39
+ *
40
+ * @since 1.0
41
+ */
42
+ function ptcfp_tags_archives( $wp_query ) {
43
+
44
+ if ( $wp_query->get( 'tag' ) )
45
+ $wp_query->set( 'post_type', 'any' );
46
+
47
+ /* I just leave this here if I need to debug stuff */
48
+ //ptcfp_print_r( $wp_query );
49
+
50
+ }
51
+
52
+ /**
53
+ * Includes the categories in archive pages
54
+ *
55
+ * Modifies the query object to include pages
56
+ * as well as posts in the items to be returned
57
+ * on archive pages
58
+ *
59
+ * @since 1.0
60
+ */
61
+ function ptcfp_category_archives( $wp_query ) {
62
+
63
+ if ( $wp_query->get( 'category_name' ) || $wp_query->get( 'cat' ) )
64
+ $wp_query->set( 'post_type', 'any' );
65
+
66
+ /* I just leave this here if I need to debug stuff */
67
+ //ptcfp_print_r( $wp_query );
68
+
69
+ }
70
+
71
+ /**
72
+ * Want to make sure that these query modifications don't
73
+ * show on the admin side or we're going to get pages and
74
+ * posts mixed in together when we click on a term
75
+ * in the admin
76
+ *
77
+ * @since 1.0
78
+ */
79
+ if( !is_admin() ) {
80
+ add_action( 'pre_get_posts', 'ptcfp_category_archives' );
81
+ add_action( 'pre_get_posts', 'ptcfp_tags_archives' );
82
+ }
83
+
84
+ /**
85
+ * Produces print_r inside <pre>
86
+ *
87
+ * @param string $data The variable we want to print
88
+ *
89
+ * @since 1.0
90
+ */
91
+ function ptcfp_print_r( $data ) {
92
+
93
+ echo "<pre>";
94
+ print_r($data);
95
+ echo "</pre>";
96
+
97
+ }
98
+ ?>
readme.txt ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Post Tags and Categories for Pages ===
2
+
3
+ Contributors: Curtis McHale
4
+ Tags: wp, tags, categories, pages
5
+ Requires at least: 3.0
6
+ Tested up to: 3.4
7
+ Stable tag: 1.0
8
+
9
+ Adds the built in WordPress categories and tags to your pages.
10
+
11
+ == Description ==
12
+
13
+ Post Tags and Categories for Pages adds the stock WordPress categories
14
+ for all of your pages. Pages will show up in the stock WordPress archive
15
+ queries.
16
+
17
+ == Installation ==
18
+
19
+ 1. Extract post-tags-categories-pages/ to your wp-content/plugins/
20
+ folder.
21
+
22
+ 2. Activate the plugin.
23
+
24
+ == Changelog ==
25
+
26
+ = 1.0 =
27
+
28
+ - relesed on WordPress repository