Hello,
I am trying to make a blog where the first post is displayed in full, but every subsequent post only has a blurb. The view has more than one page.
Right now, the code looks like this
[wpv-item index=1]
[wpv-post-link] <br> [wpv-post-date][wpv-post-body view_template="Posts"]<hr />
[wpv-item index=other]
[wpv-post-link][wpv-post-excerpt]<a href="[wpv-post-url]">Read More</a><hr />
The problem with this code is that when I go to the second page, the first item of the second page ALSO displays the full post.
I tried to make conditional code like this:
[wpv-item index=1]
[wpv-if evaluate="'[wpv-pager-current-page]' = 1"]
[wpv-post-link] <br> [wpv-post-date][wpv-post-body view_template="Posts"]<hr />
[/wpv-if]
[wpv-if evaluate="'[wpv-pager-current-page]' != 1"]
[wpv-post-link][wpv-post-excerpt]<a href="[wpv-post-url]">Read More</a><hr />
[/wpv-if]
However, this code doesn't seem to work. How can I make something only affect the first item on the first page?
Hi matthewG-2,
You are right, [wpv-if] won't works when [wpv-item] shortcode,
I suggest you try create another shortcode for it, like this:
1) add codes in your theme/functions.php
function first_item_func($atts, $content = null) {
global $WP_Views;
$res = 0;
if(isset($WP_Views->post_query->posts)){
$posts = $WP_Views->post_query->posts;
if(isset($posts[0]->ID) && (get_the_ID() == $posts[0]->ID)){
if(!isset($_REQUEST['wpv_paged']) || ($_REQUEST['wpv_paged'] == 1))
{
$res= 1;
}
}
};
return $res;
}
add_shortcode('first_item','first_item_func');
2) go to your WP admin side, Views-> settings, in section "Third-party shortcode arguments" add above shortcode name:
first_item
3) modify the codes you mentioned above as below:
[wpv-if evaluate="('[first_item]' = 1)"]
[wpv-post-link] <br> [wpv-post-date][wpv-post-body view_template="Posts"]<hr />
[/wpv-if]
[wpv-if evaluate="('[first_item]' = 0)" ]
[wpv-post-link][wpv-post-excerpt]<a href="[wpv-post-url]">Read More</a><hr />
[/wpv-if]