Version Description
- Added pagination, tweaked to turn off by default.
- Bug fixes.
Download this release
Release Info
Developer | sewmyheadon |
Plugin | Posts in Page |
Version | 1.2.2 |
Comparing to | |
See all releases |
Code changes from version 1.2.1 to 1.2.2
- assets/post-page_scripts.js +8 -8
- assets/post-page_styles.css +132 -132
- assets/posts_in_page_help_view.php +46 -48
- lib/page_posts.php +64 -63
- posts_in_page.php +41 -41
- posts_loop_template.php +5 -5
- readme.txt +12 -5
assets/post-page_scripts.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
jQuery( 'document' ).ready( function( $ ){
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
});
|
1 |
jQuery( 'document' ).ready( function( $ ){
|
2 |
+
$( '#posts-in-page-settings .top-menu li a' ).click( function(){
|
3 |
+
var toshow = $( this ).attr( 'href' ).replace( '#', '' );
|
4 |
+
$( '.top-menu li' ).removeClass( 'current-menu-tab' );
|
5 |
+
$( this ).parent( 'li' ).addClass( 'current-menu-tab' );
|
6 |
+
$( '.group' ).hide().removeClass( 'current-tab' );
|
7 |
+
$( '.' + toshow ).show().addClass( 'current-tab' );
|
8 |
+
return false;
|
9 |
+
} );
|
10 |
});
|
assets/post-page_styles.css
CHANGED
@@ -1,234 +1,234 @@
|
|
1 |
#posts-in-page-settings h2 span {
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
}
|
6 |
-
|
7 |
#side-sortables {
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
}
|
13 |
.postbox {
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
}
|
27 |
.postbox .handlediv {
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
}
|
33 |
.postbox h3 {
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
}
|
47 |
.postbox h4 {
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
}
|
57 |
.postbox .inside {
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
}
|
63 |
|
64 |
.postbox .inside_wrap{
|
65 |
-
|
66 |
}
|
67 |
.postbox .inside_wrap ul,
|
68 |
.postbox .inside_wrap p {
|
69 |
-
|
70 |
-
|
71 |
}
|
72 |
.postbox .inside_wrap ul {
|
73 |
-
|
74 |
-
|
75 |
|
76 |
}
|
77 |
.postbox ul{
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
}
|
82 |
.postbox ul li.img{
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
}
|
87 |
.postbox a{
|
88 |
-
|
89 |
-
|
90 |
}
|
91 |
.postbox a:hover{
|
92 |
-
|
93 |
}
|
94 |
|
95 |
.postbox .ivy_social li {
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
}
|
100 |
.postbox .ivy_social li a {
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
}
|
107 |
.postbox .ivy_social li.ic_fb a {
|
108 |
-
|
109 |
}
|
110 |
.postbox .ivy_social li.ic_tw a {
|
111 |
-
|
112 |
}
|
113 |
.postbox .ivy_social li.ic_li a {
|
114 |
-
|
115 |
}
|
116 |
.postbox .ivy_social li.ic_mc a {
|
117 |
-
|
118 |
}
|
119 |
.postbox .ivy_social li.ic_rss a {
|
120 |
-
|
121 |
}
|
122 |
#body-wrap {
|
123 |
-
|
124 |
}
|
125 |
#body-wrap inside {
|
126 |
-
|
127 |
}
|
128 |
#body-wrap .hndle h3 ul {
|
129 |
-
|
130 |
}
|
131 |
#body-wrap .hndle{
|
132 |
-
|
133 |
}
|
134 |
#body-wrap .hndle a{
|
135 |
-
|
136 |
}
|
137 |
#body-wrap .hndle li.current-menu-tab a{
|
138 |
-
|
139 |
-
|
140 |
}
|
141 |
#posts-in-page-settings #body-wrap{
|
142 |
-
|
143 |
-
|
144 |
}
|
145 |
#posts-in-page-settings #sidebar-wrap{
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
}
|
150 |
#posts-in-page-settings .top-menu{
|
151 |
-
|
152 |
}
|
153 |
|
154 |
#posts-in-page-settings .top-menu li{
|
155 |
-
|
156 |
-
|
157 |
}
|
158 |
#posts-in-page-settings .settings{
|
159 |
-
|
160 |
}
|
161 |
#posts-in-page-settings .help{
|
162 |
-
|
163 |
-
|
164 |
}
|
165 |
.clearfix:before, .clearfix:after {
|
166 |
-
|
167 |
-
|
168 |
.clearfix:after {
|
169 |
-
|
170 |
-
|
171 |
.clearfix {
|
172 |
-
|
173 |
-
|
174 |
#ivycat_donate form input[type="image"] {
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
|
179 |
/* MailChimp Form Embed Code - Slim - 08/17/2011 */
|
180 |
#mc_embed_signup form {
|
181 |
-
|
182 |
-
|
183 |
#mc_embed_signup h2 {
|
184 |
-
|
185 |
-
|
186 |
#mc_embed_signup input {
|
187 |
-
|
188 |
}
|
189 |
#mc_embed_signup input[type=checkbox] {
|
190 |
-
|
191 |
}
|
192 |
#mc_embed_signup input[type=radio] {
|
193 |
-
|
194 |
}
|
195 |
#mc_embed_signup input:focus {
|
196 |
-
|
197 |
}
|
198 |
#mc_embed_signup .button {
|
199 |
-
|
200 |
-
|
201 |
#mc_embed_signup .button:hover {
|
202 |
-
|
203 |
}
|
204 |
#mc_embed_signup .small-meta {
|
205 |
-
|
206 |
-
|
207 |
#mc_embed_signup .nowrap {
|
208 |
-
|
209 |
-
|
210 |
#mc_embed_signup label {
|
211 |
-
|
212 |
-
|
213 |
#mc_embed_signup input.email {
|
214 |
-
|
215 |
-
|
216 |
#mc_embed_signup input.button {
|
217 |
-
|
218 |
-
|
219 |
#mc_embed_signup div#mce-responses {
|
220 |
-
|
221 |
#mc_embed_signup div.response {
|
222 |
-
|
223 |
-
|
224 |
#mc_embed_signup #mce-error-response {
|
225 |
-
|
226 |
-
|
227 |
#mc_embed_signup #mce-success-response {
|
228 |
-
|
229 |
-
|
230 |
#mc_embed_signup label.error {
|
231 |
-
|
232 |
-
|
233 |
|
234 |
|
1 |
#posts-in-page-settings h2 span {
|
2 |
+
display:block;
|
3 |
+
width: 150px;
|
4 |
+
float: right;
|
5 |
}
|
6 |
+
|
7 |
#side-sortables {
|
8 |
+
min-height: 300px;
|
9 |
+
padding: 0;
|
10 |
+
width: 280px;
|
11 |
+
color: #333333;
|
12 |
}
|
13 |
.postbox {
|
14 |
+
background-color: #F5F5F5;
|
15 |
+
background-image: -moz-linear-gradient(center top , #F9F9F9, #F5F5F5);
|
16 |
+
border-color: #DFDFDF;
|
17 |
+
border-radius: 3px 3px 3px 3px;
|
18 |
+
box-shadow: 0 1px 0 #FFFFFF inset;
|
19 |
+
min-width: 255px;
|
20 |
+
position: relative;
|
21 |
+
border-style: solid;
|
22 |
+
border-width: 1px;
|
23 |
+
line-height: 1;
|
24 |
+
margin-bottom: 20px;
|
25 |
+
padding: 0;
|
26 |
}
|
27 |
.postbox .handlediv {
|
28 |
+
cursor: pointer;
|
29 |
+
float: right;
|
30 |
+
height: 30px;
|
31 |
+
width: 27px;
|
32 |
}
|
33 |
.postbox h3 {
|
34 |
+
font-size: 15px;
|
35 |
+
font-weight: normal;
|
36 |
+
line-height: 1;
|
37 |
+
margin: 0;
|
38 |
+
padding: 7px 10px;
|
39 |
+
color: #464646;
|
40 |
+
font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif;
|
41 |
+
text-shadow: 0 1px 0 #FFFFFF;
|
42 |
+
background-color: #F1F1F1;
|
43 |
+
background-image: -moz-linear-gradient(center top , #F9F9F9, #ECECEC);
|
44 |
+
border-bottom-color: #DFDFDF;
|
45 |
+
box-shadow: 0 1px 0 #FFFFFF;
|
46 |
}
|
47 |
.postbox h4 {
|
48 |
+
font-size: 14px;
|
49 |
+
font-weight: bold;
|
50 |
+
line-height: 1;
|
51 |
+
margin: 0;
|
52 |
+
padding: 7px 0;
|
53 |
+
color: #464646;
|
54 |
+
text-align: left;
|
55 |
+
text-shadow: 0 1px 0 #FFFFFF;
|
56 |
}
|
57 |
.postbox .inside {
|
58 |
+
margin: 6px 0 8px;
|
59 |
+
position: relative;
|
60 |
+
line-height: 1.4em;
|
61 |
+
padding:0 ;
|
62 |
}
|
63 |
|
64 |
.postbox .inside_wrap{
|
65 |
+
margin:0 15px;
|
66 |
}
|
67 |
.postbox .inside_wrap ul,
|
68 |
.postbox .inside_wrap p {
|
69 |
+
margin-top:0;
|
70 |
+
font-size:13px;margin-bottom:0.7em;
|
71 |
}
|
72 |
.postbox .inside_wrap ul {
|
73 |
+
list-style:disc;
|
74 |
+
margin-left:15px;
|
75 |
|
76 |
}
|
77 |
.postbox ul{
|
78 |
+
list-style-type: none;
|
79 |
+
padding: 0;
|
80 |
+
margin-top: 0;
|
81 |
}
|
82 |
.postbox ul li.img{
|
83 |
+
text-align: center;
|
84 |
+
background: #ffffff;
|
85 |
+
padding: 10px 0 ;
|
86 |
}
|
87 |
.postbox a{
|
88 |
+
color: #628C29;
|
89 |
+
text-decoration: none;
|
90 |
}
|
91 |
.postbox a:hover{
|
92 |
+
color: #8EC73C;
|
93 |
}
|
94 |
|
95 |
.postbox .ivy_social li {
|
96 |
+
list-style-type:none;
|
97 |
+
text-indent:-9999px;
|
98 |
+
display:inline;
|
99 |
}
|
100 |
.postbox .ivy_social li a {
|
101 |
+
display:block;
|
102 |
+
float:left;
|
103 |
+
width:16px;
|
104 |
+
height:16px;
|
105 |
+
margin:0 12px;
|
106 |
}
|
107 |
.postbox .ivy_social li.ic_fb a {
|
108 |
+
background: url("facebook.png") no-repeat top left;
|
109 |
}
|
110 |
.postbox .ivy_social li.ic_tw a {
|
111 |
+
background: url("twitter.png") no-repeat top left;
|
112 |
}
|
113 |
.postbox .ivy_social li.ic_li a {
|
114 |
+
background: url("linkedin.png") no-repeat top left;
|
115 |
}
|
116 |
.postbox .ivy_social li.ic_mc a {
|
117 |
+
background: url("email.png") no-repeat top left;
|
118 |
}
|
119 |
.postbox .ivy_social li.ic_rss a {
|
120 |
+
background: url("feed.png") no-repeat top left;
|
121 |
}
|
122 |
#body-wrap {
|
123 |
+
margin-top: 25px;
|
124 |
}
|
125 |
#body-wrap inside {
|
126 |
+
padding: 10px;
|
127 |
}
|
128 |
#body-wrap .hndle h3 ul {
|
129 |
+
margin-bottom: 0;
|
130 |
}
|
131 |
#body-wrap .hndle{
|
132 |
+
margin-bottom: 10px;
|
133 |
}
|
134 |
#body-wrap .hndle a{
|
135 |
+
font-size: 18px;
|
136 |
}
|
137 |
#body-wrap .hndle li.current-menu-tab a{
|
138 |
+
font-size: 21px;
|
139 |
+
font-weight: bold;
|
140 |
}
|
141 |
#posts-in-page-settings #body-wrap{
|
142 |
+
width: 55%;
|
143 |
+
float:left;
|
144 |
}
|
145 |
#posts-in-page-settings #sidebar-wrap{
|
146 |
+
width: 35%;
|
147 |
+
float:left;
|
148 |
+
margin: 25px 0 0 20px;
|
149 |
}
|
150 |
#posts-in-page-settings .top-menu{
|
151 |
+
width: 100%;
|
152 |
}
|
153 |
|
154 |
#posts-in-page-settings .top-menu li{
|
155 |
+
margin-bottom: 0px;
|
156 |
+
text-align: center;
|
157 |
}
|
158 |
#posts-in-page-settings .settings{
|
159 |
+
padding: 10px;
|
160 |
}
|
161 |
#posts-in-page-settings .help{
|
162 |
+
margin-top: 20px;
|
163 |
+
padding: 10px;
|
164 |
}
|
165 |
.clearfix:before, .clearfix:after {
|
166 |
+
content: ""; display: table;
|
167 |
+
}
|
168 |
.clearfix:after {
|
169 |
+
clear: both;
|
170 |
+
}
|
171 |
.clearfix {
|
172 |
+
*zoom: 1;
|
173 |
+
}
|
174 |
#ivycat_donate form input[type="image"] {
|
175 |
+
margin:0 auto;
|
176 |
+
display:block;
|
177 |
+
}
|
178 |
|
179 |
/* MailChimp Form Embed Code - Slim - 08/17/2011 */
|
180 |
#mc_embed_signup form {
|
181 |
+
display:block; position:relative; text-align:left; padding:10px 0 10px 0;width: 250px;
|
182 |
+
}
|
183 |
#mc_embed_signup h2 {
|
184 |
+
font-weight:bold; padding:0; margin:15px 0; font-size:1.4em;
|
185 |
+
}
|
186 |
#mc_embed_signup input {
|
187 |
+
border:1px solid #999; -webkit-appearance:none;
|
188 |
}
|
189 |
#mc_embed_signup input[type=checkbox] {
|
190 |
+
-webkit-appearance:checkbox;
|
191 |
}
|
192 |
#mc_embed_signup input[type=radio] {
|
193 |
+
-webkit-appearance:radio;
|
194 |
}
|
195 |
#mc_embed_signup input:focus {
|
196 |
+
border-color:#333;
|
197 |
}
|
198 |
#mc_embed_signup .button {
|
199 |
+
clear:both; background-color: #aaa; border: 0 none; border-radius:4px; color: #FFFFFF; cursor: pointer; display: inline-block; font-size:15px; font-weight: bold; height: 32px; line-height: 32px; margin: 0 5px 10px 0; padding:0; text-align: center; text-decoration: none; vertical-align: top; white-space: nowrap; width: auto;
|
200 |
+
}
|
201 |
#mc_embed_signup .button:hover {
|
202 |
+
background-color:#777;
|
203 |
}
|
204 |
#mc_embed_signup .small-meta {
|
205 |
+
font-size: 11px;
|
206 |
+
}
|
207 |
#mc_embed_signup .nowrap {
|
208 |
+
white-space:nowrap;
|
209 |
+
}
|
210 |
#mc_embed_signup label {
|
211 |
+
display:block; font-size:14px; padding-bottom:10px; font-weight:bold;color:#464646
|
212 |
+
}
|
213 |
#mc_embed_signup input.email {
|
214 |
+
display:block; padding:8px 0; margin:0 0 10px 0; text-indent:5px; width:58%; min-width:130px;float:left;
|
215 |
+
}
|
216 |
#mc_embed_signup input.button {
|
217 |
+
display:block; clear:none; background:#628C29; width:35%; margin:0 0 10px 0; min-width:90px;float:right;text-shadow:0 1px 0 #666;
|
218 |
+
}
|
219 |
#mc_embed_signup div#mce-responses {
|
220 |
+
float:left; top:-1.4em; padding:0em .5em 0em .5em; overflow:hidden; width:90%;margin: 0 5%; clear: both;}
|
221 |
#mc_embed_signup div.response {
|
222 |
+
margin:1em 0; padding:1em .5em .5em 0; font-weight:bold; float:left; top:-1.5em; z-index:1; width:80%;
|
223 |
+
}
|
224 |
#mc_embed_signup #mce-error-response {
|
225 |
+
display:none;
|
226 |
+
}
|
227 |
#mc_embed_signup #mce-success-response {
|
228 |
+
color:#529214; display:none;
|
229 |
+
}
|
230 |
#mc_embed_signup label.error {
|
231 |
+
display:block; float:none; width:auto; margin-left:1.05em; text-align:left; padding:.5em 0;
|
232 |
+
}
|
233 |
|
234 |
|
assets/posts_in_page_help_view.php
CHANGED
@@ -1,51 +1,49 @@
|
|
1 |
<div class="wrap" id="posts-in-page-settings">
|
2 |
<div id="icon-options-general" class="icon32"></div>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
<?php require_once 'desc.php'; ?>
|
50 |
-
</div>
|
51 |
</div>
|
1 |
<div class="wrap" id="posts-in-page-settings">
|
2 |
<div id="icon-options-general" class="icon32"></div>
|
3 |
+
<h2>Posts in Page</h2>
|
4 |
+
<div id="body-wrap" class="meta-box-sortables ui-sortable">
|
5 |
+
<div id="metabox_desc" class="postbox">
|
6 |
+
<div class="handlediv" title="Click to toggle">
|
7 |
+
<br>
|
8 |
+
</div>
|
9 |
+
<div class="hndle">
|
10 |
+
<h3><ul class="top-menu clearfix">
|
11 |
+
<li class="menu-item"><a href="#help">Shortcode Usage</a></li>
|
12 |
+
</ul></h3>
|
13 |
+
</div>
|
14 |
+
<div class="group help inside">
|
15 |
+
<p>To 'pull' posts into a page, you can either:</p>
|
16 |
+
|
17 |
+
<ol>
|
18 |
+
<li>place a shortcode in the editor window of the page you're editing, or </li>
|
19 |
+
<li>modify a theme template file using the shortcode in a PHP function.</li>
|
20 |
+
</ol>
|
21 |
+
|
22 |
+
<h4>Using Shortcodes in the WordPress editor</h4>
|
23 |
+
|
24 |
+
<ul>
|
25 |
+
<li><code>[ic_add_posts]</code> - Add all posts to a page (limit to what number posts in WordPress is set to), essentially adds blog "page" to page.</li>
|
26 |
+
<li><code>[ic_add_posts ids='1,2,3']</code> - show one or many posts by specifying the post ID(s) ( specify all post types )</li>
|
27 |
+
<li><code>[ic_add_posts post_type='post_type']</code> - show posts from a custom post type by specifying the post type slug ( must give post type if not a standard post ) add multiple post types by separating with commas (ex. <code>post_type='post_type1,post_type2'</code>)</li>
|
28 |
+
<li><code>[ic_add_posts showposts='5']</code> - limit number of posts (or override default setting)</li>
|
29 |
+
<li><code>[ic_add_posts orderby='title' order='ASC']</code> - orderby title - supports all WP orderby variables. Order is optional, WP default </li>
|
30 |
+
<li><code>[ic_add_posts category='category-slug']</code> - Show posts within a specific category. Uses slugs, can have multiple but separate by commas. category-1,category2, etc (no spaces.)</li>
|
31 |
+
<li><code>[ic_add_posts tag='tag-slug']</code> - Show posts using a specific tag. Like categories, it uses slugs, and can accommodate multiple tags separate by commas. tag-1,tag-2, etc (no spaces.)</li>
|
32 |
+
<li><code>[ic_add_posts tax='taxonomy' term='term']</code> - limit posts to those that exist in a taxonomy and have a specific term. Both are required for either one to work</li>
|
33 |
+
<li><code>[ic_add_posts template='template-in-theme-dir.php']</code> - In case you want to style your markup, add meta data, etc. Each shortcode can reference a different template. These templates must exist in the theme directory.</li>
|
34 |
+
</ul>
|
35 |
+
|
36 |
+
<p>Or any combination of the above.</p>
|
37 |
+
|
38 |
+
<h4>Using Shortcodes within a PHP function</h4>
|
39 |
+
|
40 |
+
<p>If you'd like to use this plugin to pull posts directly into your theme's template files, you can drop the following WordPress function in your template files, replacing the <code>[shortcode]</code> part with your, custom shortcode.</p>
|
41 |
+
|
42 |
+
<pre><code><?php echo do_shortcode("[shortcode]"); ?></code></pre>
|
43 |
+
</div>
|
44 |
+
</div>
|
45 |
+
</div>
|
46 |
+
<div id="sidebar-wrap">
|
47 |
+
<?php require_once 'desc.php'; ?>
|
48 |
+
</div>
|
|
|
|
|
49 |
</div>
|
lib/page_posts.php
CHANGED
@@ -9,15 +9,16 @@ if ( !function_exists( 'add_action' ) )
|
|
9 |
class ICPagePosts {
|
10 |
|
11 |
protected $args = array(
|
12 |
-
'post_type'
|
13 |
-
'post_status'
|
14 |
-
'orderby'
|
15 |
-
'order'
|
16 |
-
'
|
|
|
17 |
); // set defaults for wp_parse_args
|
18 |
|
19 |
public function __construct( $atts ) {
|
20 |
-
|
21 |
}
|
22 |
|
23 |
/**
|
@@ -26,20 +27,21 @@ class ICPagePosts {
|
|
26 |
* @return string output of template file
|
27 |
*/
|
28 |
public function output_posts() {
|
29 |
-
if ( !$this->args )
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
33 |
while ( $page_posts->have_posts( ) ):
|
34 |
$output .= self::add_template_part( $page_posts );
|
35 |
endwhile;
|
36 |
-
$output .= '<div class="pip-nav">' . apply_filters( 'posts_in_page_paginate',
|
37 |
$this->paginate_links( $page_posts )
|
38 |
-
) . '</div>';
|
39 |
endif;
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
|
44 |
protected function paginate_links( $posts ){
|
45 |
global $wp_query;
|
@@ -59,11 +61,11 @@ class ICPagePosts {
|
|
59 |
*
|
60 |
* @param array $atts Attritubes for building the $args array.
|
61 |
*/
|
62 |
-
|
63 |
-
|
64 |
$this->args['posts_per_page'] = get_option( 'posts_per_page' );
|
65 |
// parse the arguments using the defaults
|
66 |
-
|
67 |
|
68 |
// multiple post types are indicated, pass as an array
|
69 |
if( preg_match( '`,`', $this->args['post_type'] ) ){
|
@@ -72,47 +74,46 @@ class ICPagePosts {
|
|
72 |
}
|
73 |
|
74 |
// Show specific posts by ID
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
|
81 |
// Use a specified template
|
82 |
-
|
83 |
$this->args['template'] = $atts['template'];
|
84 |
-
|
85 |
// get posts in a certain category by name (slug)
|
86 |
if ( isset( $atts['category'] ) ) {
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
|
92 |
// Do a tex query, tax and term a required.
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
|
102 |
// get posts with a certain tag
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
}
|
107 |
|
108 |
// show number of posts (default is 10, showposts or posts_per_page are both valid, only one is needed)
|
109 |
-
|
110 |
$this->args[ 'posts_per_page' ] = $atts['showposts'];
|
111 |
|
112 |
// handle pagination (for code, template pagination is in the template)
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
|
117 |
if ( ! isset( $this->args['ignore_sticky_posts'] ) ) {
|
118 |
$this->args['post__not_in'] = get_option( 'sticky_posts' );
|
@@ -123,41 +124,41 @@ class ICPagePosts {
|
|
123 |
}
|
124 |
|
125 |
$this->args = apply_filters( 'posts_in_page_args', $this->args );
|
126 |
-
|
127 |
-
|
128 |
/**
|
129 |
* Tests if a theme has a theme template file that exists
|
130 |
*
|
131 |
* @return true if template exists, false otherwise.
|
132 |
*/
|
133 |
-
|
134 |
-
|
135 |
? get_stylesheet_directory( ) . '/' . $this->args['template'] // use specified template file
|
136 |
: get_stylesheet_directory( ) . '/posts_loop_template.php'; // use default template file
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
/**
|
142 |
* Retrieves the post loop template and returns the output
|
143 |
*
|
144 |
* @return string results of the output
|
145 |
*/
|
146 |
protected function add_template_part( $ic_posts, $singles=false ) {
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
$output = '';
|
153 |
-
|
154 |
$output .= apply_filters( 'posts_in_page_pre_loop', '' );
|
155 |
-
|
156 |
? $file_path // use template file in theme
|
157 |
: POSTSPAGE_DIR . '/posts_loop_template.php'; // use default plugin template file
|
158 |
-
|
159 |
$output .= apply_filters( 'posts_in_page_post_loop', '' );
|
160 |
-
|
161 |
}
|
162 |
|
163 |
-
}
|
9 |
class ICPagePosts {
|
10 |
|
11 |
protected $args = array(
|
12 |
+
'post_type' => 'post',
|
13 |
+
'post_status' => 'publish',
|
14 |
+
'orderby' => 'date',
|
15 |
+
'order' => 'DESC',
|
16 |
+
'paginate' => false,
|
17 |
+
'template' => false
|
18 |
); // set defaults for wp_parse_args
|
19 |
|
20 |
public function __construct( $atts ) {
|
21 |
+
self::set_args( $atts );
|
22 |
}
|
23 |
|
24 |
/**
|
27 |
* @return string output of template file
|
28 |
*/
|
29 |
public function output_posts() {
|
30 |
+
if ( !$this->args )
|
31 |
+
return '';
|
32 |
+
$page_posts = apply_filters( 'posts_in_page_results', new WP_Query( $this->args ) ); // New WP_Query object
|
33 |
+
$output = '';
|
34 |
+
if ( $page_posts->have_posts( ) ):
|
35 |
while ( $page_posts->have_posts( ) ):
|
36 |
$output .= self::add_template_part( $page_posts );
|
37 |
endwhile;
|
38 |
+
$output .= ( $this->args['paginate'] ) ? '<div class="pip-nav">' . apply_filters( 'posts_in_page_paginate',
|
39 |
$this->paginate_links( $page_posts )
|
40 |
+
) . '</div>' : '';
|
41 |
endif;
|
42 |
+
wp_reset_postdata( );
|
43 |
+
return $output;
|
44 |
+
}
|
45 |
|
46 |
protected function paginate_links( $posts ){
|
47 |
global $wp_query;
|
61 |
*
|
62 |
* @param array $atts Attritubes for building the $args array.
|
63 |
*/
|
64 |
+
protected function set_args( $atts ) {
|
65 |
+
global $wp_query;
|
66 |
$this->args['posts_per_page'] = get_option( 'posts_per_page' );
|
67 |
// parse the arguments using the defaults
|
68 |
+
$this->args = wp_parse_args( $atts, $this->args );
|
69 |
|
70 |
// multiple post types are indicated, pass as an array
|
71 |
if( preg_match( '`,`', $this->args['post_type'] ) ){
|
74 |
}
|
75 |
|
76 |
// Show specific posts by ID
|
77 |
+
if ( isset( $atts['ids'] ) ) {
|
78 |
+
$post_ids = explode( ',', $atts['ids'] );
|
79 |
+
$this->args['post__in'] = $post_ids;
|
80 |
+
$this->args['posts_per_page'] = count( $post_ids );
|
81 |
+
}
|
82 |
|
83 |
// Use a specified template
|
84 |
+
if ( isset( $atts['template'] ) )
|
85 |
$this->args['template'] = $atts['template'];
|
86 |
+
|
87 |
// get posts in a certain category by name (slug)
|
88 |
if ( isset( $atts['category'] ) ) {
|
89 |
+
$this->args['category_name'] = $atts['category'];
|
90 |
+
} elseif ( isset( $atts['cats'] ) ) { // get posts in a certain category by id
|
91 |
+
$this->args['cat'] = $atts['cats'];
|
92 |
+
}
|
93 |
|
94 |
// Do a tex query, tax and term a required.
|
95 |
+
if( isset( $atts['tax'] ) ) {
|
96 |
+
if( isset( $atts['term'] ) ){
|
97 |
+
$terms = explode( ',', $atts['term'] );
|
98 |
+
$this->args['tax_query'] = array(
|
99 |
+
array( 'taxonomy' => $atts['tax'], 'field' => 'slug', 'terms' => ( count( $terms ) > 1 ) ? $terms : $atts['term'] )
|
100 |
+
);
|
101 |
+
}
|
102 |
+
}
|
103 |
|
104 |
// get posts with a certain tag
|
105 |
+
if ( isset( $atts['tag'] ) ) {
|
106 |
+
$this->args['tag'] = $atts['tag'];
|
107 |
+
}
|
|
|
108 |
|
109 |
// show number of posts (default is 10, showposts or posts_per_page are both valid, only one is needed)
|
110 |
+
if ( isset( $atts['showposts'] ) )
|
111 |
$this->args[ 'posts_per_page' ] = $atts['showposts'];
|
112 |
|
113 |
// handle pagination (for code, template pagination is in the template)
|
114 |
+
if ( isset( $wp_query->query_vars['page'] ) && $wp_query->query_vars['page'] > 1 ) {
|
115 |
+
$this->args['paged'] = $wp_query->query_vars['page'];
|
116 |
+
}
|
117 |
|
118 |
if ( ! isset( $this->args['ignore_sticky_posts'] ) ) {
|
119 |
$this->args['post__not_in'] = get_option( 'sticky_posts' );
|
124 |
}
|
125 |
|
126 |
$this->args = apply_filters( 'posts_in_page_args', $this->args );
|
127 |
+
}
|
128 |
+
|
129 |
/**
|
130 |
* Tests if a theme has a theme template file that exists
|
131 |
*
|
132 |
* @return true if template exists, false otherwise.
|
133 |
*/
|
134 |
+
protected function has_theme_template( ) {
|
135 |
+
$template_file = ( $this->args['template'] )
|
136 |
? get_stylesheet_directory( ) . '/' . $this->args['template'] // use specified template file
|
137 |
: get_stylesheet_directory( ) . '/posts_loop_template.php'; // use default template file
|
138 |
+
|
139 |
+
return ( file_exists( $template_file ) ) ? $template_file : false;
|
140 |
+
}
|
141 |
+
|
142 |
/**
|
143 |
* Retrieves the post loop template and returns the output
|
144 |
*
|
145 |
* @return string results of the output
|
146 |
*/
|
147 |
protected function add_template_part( $ic_posts, $singles=false ) {
|
148 |
+
if ( $singles ) {
|
149 |
+
setup_postdata( $ic_posts );
|
150 |
+
} else {
|
151 |
+
$ic_posts->the_post( );
|
152 |
+
}
|
153 |
$output = '';
|
154 |
+
ob_start( );
|
155 |
$output .= apply_filters( 'posts_in_page_pre_loop', '' );
|
156 |
+
require ( $file_path = self::has_theme_template( ) )
|
157 |
? $file_path // use template file in theme
|
158 |
: POSTSPAGE_DIR . '/posts_loop_template.php'; // use default plugin template file
|
159 |
+
$output .= ob_get_contents( );
|
160 |
$output .= apply_filters( 'posts_in_page_post_loop', '' );
|
161 |
+
return ob_get_clean( );
|
162 |
}
|
163 |
|
164 |
+
}
|
posts_in_page.php
CHANGED
@@ -6,12 +6,12 @@
|
|
6 |
* Description: Easily add one or more posts to any page using simple shortcodes. Supports categories, tags, custom post types, custom taxonomies, and more.
|
7 |
* Author: IvyCat Web Services
|
8 |
* Author URI: http://www.ivycat.com
|
9 |
-
* version: 1.2.
|
10 |
* License: GNU General Public License v2.0
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
13 |
------------------------------------------------------------------------
|
14 |
-
IvyCat Posts in Page, Copyright 2012 IvyCat, Inc. (admins@ivycat.com)
|
15 |
|
16 |
This program is free software; you can redistribute it and/or modify
|
17 |
it under the terms of the GNU General Public License as published by
|
@@ -41,73 +41,73 @@ if ( ! defined( 'POSTPAGE_URL' ) )
|
|
41 |
require_once 'lib/page_posts.php';
|
42 |
|
43 |
class ICAddPostsToPage {
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
/**
|
53 |
* Add settings link on plugins page.
|
54 |
*/
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
|
61 |
/**
|
62 |
-
* Main
|
63 |
*
|
64 |
* @param array $atts An array of shortcode parameters. None required
|
65 |
*/
|
66 |
-
|
67 |
-
|
68 |
return $posts->output_posts( );
|
69 |
-
|
70 |
|
71 |
/**
|
72 |
-
* Deprecated
|
73 |
*
|
74 |
* @todo Remove this depreciated function.
|
75 |
*/
|
76 |
public function post_in_page( $atts ) {
|
77 |
-
|
78 |
}
|
79 |
|
80 |
/**
|
81 |
-
* Init
|
82 |
*/
|
83 |
-
|
84 |
-
|
85 |
return;
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
|
96 |
/**
|
97 |
-
* Enqueue
|
98 |
*/
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
|
104 |
/**
|
105 |
-
* Plugin
|
106 |
*/
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
}
|
112 |
|
113 |
/**
|
6 |
* Description: Easily add one or more posts to any page using simple shortcodes. Supports categories, tags, custom post types, custom taxonomies, and more.
|
7 |
* Author: IvyCat Web Services
|
8 |
* Author URI: http://www.ivycat.com
|
9 |
+
* version: 1.2.2
|
10 |
* License: GNU General Public License v2.0
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
13 |
------------------------------------------------------------------------
|
14 |
+
IvyCat Posts in Page, Copyright 2012 -2013 IvyCat, Inc. (admins@ivycat.com)
|
15 |
|
16 |
This program is free software; you can redistribute it and/or modify
|
17 |
it under the terms of the GNU General Public License as published by
|
41 |
require_once 'lib/page_posts.php';
|
42 |
|
43 |
class ICAddPostsToPage {
|
44 |
+
|
45 |
+
public function __construct( ) {
|
46 |
+
add_shortcode( 'ic_add_posts', array( &$this, 'posts_in_page' ) );
|
47 |
+
add_shortcode( 'ic_add_post', array( &$this, 'post_in_page' ) );
|
48 |
+
add_action( 'admin_menu', array( &$this, 'plugin_page_init' ) );
|
49 |
+
add_filter( 'plugin_action_links_'. plugin_basename( __FILE__ ), array( &$this, 'plugin_action_links' ), 10, 4 );
|
50 |
+
}
|
51 |
+
|
52 |
/**
|
53 |
* Add settings link on plugins page.
|
54 |
*/
|
55 |
+
public function plugin_action_links( $actions, $plugin_file, $plugin_data, $context ) {
|
56 |
+
if ( is_plugin_active( $plugin_file ) )
|
57 |
+
$actions[] = '<a href="' . admin_url('options-general.php?page=posts_in_page') . '">' . __( ' Help', 'posts_in_page' ) . '</a>';
|
58 |
+
return apply_filters( 'post_in_page_actions', $actions );
|
59 |
+
}
|
60 |
|
61 |
/**
|
62 |
+
* Main shortcode
|
63 |
*
|
64 |
* @param array $atts An array of shortcode parameters. None required
|
65 |
*/
|
66 |
+
public function posts_in_page( $atts ) {
|
67 |
+
$posts = new ICPagePosts( $atts );
|
68 |
return $posts->output_posts( );
|
69 |
+
}
|
70 |
|
71 |
/**
|
72 |
+
* Deprecated shortcode (routing to posts in page function now)
|
73 |
*
|
74 |
* @todo Remove this depreciated function.
|
75 |
*/
|
76 |
public function post_in_page( $atts ) {
|
77 |
+
return self::posts_in_page( $atts );
|
78 |
}
|
79 |
|
80 |
/**
|
81 |
+
* Init plugin, add menu page, and setup hooks to load assets on the plugin options page
|
82 |
*/
|
83 |
+
public function plugin_page_init() {
|
84 |
+
if ( ! current_user_can( 'administrator' ) )
|
85 |
return;
|
86 |
|
87 |
+
$hooks = array( );
|
88 |
+
$hooks[] = add_options_page( __( 'Posts In Page' ), __( 'Posts In Page' ), 'read', 'posts_in_page',
|
89 |
+
array( $this, 'plugin_page' ) );
|
90 |
|
91 |
+
foreach ( $hooks as $hook ) {
|
92 |
+
add_action( "admin_print_styles-{$hook}", array( $this, 'load_assets' ) );
|
93 |
+
}
|
94 |
+
}
|
95 |
|
96 |
/**
|
97 |
+
* Enqueue plugin assets (scripts & styles)
|
98 |
*/
|
99 |
+
public function load_assets( ) {
|
100 |
+
wp_enqueue_style( 'postpagestyle', POSTPAGE_URL. '/assets/post-page_styles.css' );
|
101 |
+
wp_enqueue_script( 'postpagescript', POSTPAGE_URL. '/assets/post-page_scripts.js' );
|
102 |
+
}
|
103 |
|
104 |
/**
|
105 |
+
* Plugin Settings page - includes view for the page
|
106 |
*/
|
107 |
+
public function plugin_page( ) {
|
108 |
+
require_once 'assets/posts_in_page_help_view.php';
|
109 |
+
}
|
110 |
+
|
111 |
}
|
112 |
|
113 |
/**
|
posts_loop_template.php
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
<!--
|
2 |
-
directory so
|
3 |
|
4 |
<!-- Start of Post Wrap -->
|
5 |
<div class="post hentry ivycat-post">
|
6 |
-
<!-- This is the output of the post
|
7 |
<h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
|
8 |
|
9 |
-
<!-- This is the output of the
|
10 |
<div class="entry-summary">
|
11 |
<?php the_excerpt(); ?>
|
12 |
</div>
|
13 |
|
14 |
-
<!-- This is the output of the
|
15 |
<div class="entry-utility">
|
16 |
<?php if ( count( get_the_category() ) ) : ?>
|
17 |
<span class="cat-links">
|
1 |
+
<!-- NOTE: If you need to make changes to this file, copy it to your current theme's main
|
2 |
+
directory so your changes won't be overwritten when the plugin is upgraded. -->
|
3 |
|
4 |
<!-- Start of Post Wrap -->
|
5 |
<div class="post hentry ivycat-post">
|
6 |
+
<!-- This is the output of the post TITLE -->
|
7 |
<h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
|
8 |
|
9 |
+
<!-- This is the output of the EXCERPT -->
|
10 |
<div class="entry-summary">
|
11 |
<?php the_excerpt(); ?>
|
12 |
</div>
|
13 |
|
14 |
+
<!-- This is the output of the META information -->
|
15 |
<div class="entry-utility">
|
16 |
<?php if ( count( get_the_category() ) ) : ?>
|
17 |
<span class="cat-links">
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: dgilfoy, ivycat, sewmyheadon
|
|
3 |
Donate link: http://www.ivycat.com/contribute/
|
4 |
Tags: shortcode, pages, posts, custom post types
|
5 |
Requires at least: 3.0
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag: 1.2.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -52,6 +52,7 @@ To 'pull' posts into a page, you can either:
|
|
52 |
* `[ic_add_posts tax='taxonomy' term='term']` - limit posts to those that exist in a taxonomy and have a specific term. Both are required for either one to work
|
53 |
* `[ic_add_posts template='template-in-theme-dir.php']` - In case you want to style your markup, add meta data, etc. Each shortcode can reference a different template. These templates must exist in the theme directory.
|
54 |
* `[ic_add_posts ignore_sticky_posts='no']` - Show sticky posts too (they're ignored by default).
|
|
|
55 |
|
56 |
Or any combination of the above.
|
57 |
|
@@ -76,9 +77,9 @@ Alright, now lets say that you want to pull in all posts from two categories int
|
|
76 |
Now, you're ambitious and want to try something complex. Let's say you've got a page called _Plugins Are Awesome_ and, in it, you want to pull in posts that match the following criteria:
|
77 |
|
78 |
* posts from a custom post type called _Testimonials_,
|
79 |
-
* posts that are in the _Testimonial Type_ custom taxonomy using the term _Customer_
|
80 |
* you want to display six testimonials per page,
|
81 |
-
* you'd like them displayed in ascending order
|
82 |
* finally, you've created a custom template to use in presenting these posts and named it `my-posts-in-page-template.php`
|
83 |
|
84 |
Your shortcode might look like this:
|
@@ -126,6 +127,10 @@ Not likely, but let us know if it does; then we'll know we have something specia
|
|
126 |
|
127 |
== Changelog ==
|
128 |
|
|
|
|
|
|
|
|
|
129 |
= 1.2.1 =
|
130 |
* Added code to allow ignoring, or showing of sticky posts. By default, sticky posts are ignored, but can be re-enabled using the shortcode `[ic_add_posts ignore_sticky_posts='no']`.
|
131 |
|
@@ -134,7 +139,6 @@ Not likely, but let us know if it does; then we'll know we have something specia
|
|
134 |
* Added post pagination
|
135 |
* Plugin now honors default post reading settings under Settings/Reading in the WordPress Dashboard.
|
136 |
* Improved and simplified documentation.
|
137 |
-
* Added filters & hooks (documentation coming)
|
138 |
|
139 |
= 1.1.1 =
|
140 |
* Code maintenance, fix for category bug, also added ability for multiple post types per shortcode.
|
@@ -166,6 +170,9 @@ Not likely, but let us know if it does; then we'll know we have something specia
|
|
166 |
|
167 |
== Upgrade Notice ==
|
168 |
|
|
|
|
|
|
|
169 |
= 1.2.1 =
|
170 |
* Small feature update, not critical.
|
171 |
|
3 |
Donate link: http://www.ivycat.com/contribute/
|
4 |
Tags: shortcode, pages, posts, custom post types
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 3.5.1
|
7 |
+
Stable tag: 1.2.2
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
52 |
* `[ic_add_posts tax='taxonomy' term='term']` - limit posts to those that exist in a taxonomy and have a specific term. Both are required for either one to work
|
53 |
* `[ic_add_posts template='template-in-theme-dir.php']` - In case you want to style your markup, add meta data, etc. Each shortcode can reference a different template. These templates must exist in the theme directory.
|
54 |
* `[ic_add_posts ignore_sticky_posts='no']` - Show sticky posts too (they're ignored by default).
|
55 |
+
* `[ic_add_posts paginate='yes']` - use pagination links (off by default)
|
56 |
|
57 |
Or any combination of the above.
|
58 |
|
77 |
Now, you're ambitious and want to try something complex. Let's say you've got a page called _Plugins Are Awesome_ and, in it, you want to pull in posts that match the following criteria:
|
78 |
|
79 |
* posts from a custom post type called _Testimonials_,
|
80 |
+
* posts that are in the _Testimonial Type_ custom taxonomy using the term _Customer_,
|
81 |
* you want to display six testimonials per page,
|
82 |
+
* you'd like them displayed in ascending order,
|
83 |
* finally, you've created a custom template to use in presenting these posts and named it `my-posts-in-page-template.php`
|
84 |
|
85 |
Your shortcode might look like this:
|
127 |
|
128 |
== Changelog ==
|
129 |
|
130 |
+
= 1.2.2 =
|
131 |
+
* Added pagination, tweaked to turn off by default.
|
132 |
+
* Bug fixes.
|
133 |
+
|
134 |
= 1.2.1 =
|
135 |
* Added code to allow ignoring, or showing of sticky posts. By default, sticky posts are ignored, but can be re-enabled using the shortcode `[ic_add_posts ignore_sticky_posts='no']`.
|
136 |
|
139 |
* Added post pagination
|
140 |
* Plugin now honors default post reading settings under Settings/Reading in the WordPress Dashboard.
|
141 |
* Improved and simplified documentation.
|
|
|
142 |
|
143 |
= 1.1.1 =
|
144 |
* Code maintenance, fix for category bug, also added ability for multiple post types per shortcode.
|
170 |
|
171 |
== Upgrade Notice ==
|
172 |
|
173 |
+
= 1.2.2 =
|
174 |
+
* Small bug fixes for tags, pagination; not critical.
|
175 |
+
|
176 |
= 1.2.1 =
|
177 |
* Small feature update, not critical.
|
178 |
|