Skip Navigation

[Closed] Changing the first post on the first page of a view.

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 9 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 9 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#240954

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?

#241092

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]

The topic ‘[Closed] Changing the first post on the first page of a view.’ is closed to new replies.