Skip Navigation

[Resolved] Link a post to multiple views

This support ticket is created 4 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 7 replies, has 2 voices.

Last updated by Minesh 4 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#1912653

Hello,

Is their a way to link a post to multiple views? I tried the ID included / exclude but its not yielding the results I want. It either removes all the post and only displays the one or makes me tediously exclude 45+ posts from views so the right ones still appear on the page... The only other thing I can think of is to create more views and call the view "view-category-1-view-category-2" so I can remember these are the post that need to be in both views. I can't imagine this is the only way because it seem inefficient.

#1912805

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I do not understand yet what is your goal or what you what to achieve as its still not clear with the description you shared with your first reply.

Can you please share more details what exactly you want to display and what content you want to filter. Maybe share a test case example that should help me to understand your issue or some screenshots?

Once I get the clarity about what exactly you want then I will be able to guide you in the right direction.

#1913299
views.JPG

Hello Minesh,

I included an image. I would like to add a single post from another view and add it to a new view loop without showing all the other post within that original group.

ex. Correctional Lighting post (id=2412) add to view high Abuse Lighting.

#1913379

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The thing is that you can not differentiate the view's loop as it will continuously work until it ends.

If you can explain me the reason why you want one specific post from another post type then I can guide you in the right direction.

You can display the output like:
- The specific post you want to display
- Then the whole view's loop

But I first would like to know how exactly you want to display that specific post? at what section of page, what things you want to display for that specific post?

#1913659

We have several products that have universal uses. Our loops have the same templates as well.

Here is the loop code:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<wpv-loop wrap="3" pad="true">
		[wpv-item index=1]
		<div class="row ">
        
			<div class="col-sm-4">[wpv-post-body view_template="Loop item in High Abuse"]</div>
		[wpv-item index=other]
			<div class="col-sm-4">[wpv-post-body view_template="Loop item in High Abuse"]</div>
		[wpv-item index=3]
			<div class="col-sm-4">[wpv-post-body view_template="Loop item in High Abuse"]</div>
		</div>
		[wpv-item index=pad]
			<div class="col-sm-4"></div>
		[wpv-item index=pad-last]
			<div class="col-sm-4"></div>
		</div>
	</wpv-loop>

	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

Here is the template code:

<div class="catalog-pod"><div class="header-dec"><h5 class="headerText">[types field='header-descriptions'][/types]</h5></div>[types field='catalog-image'][/types]
<div class="catalog-info">
  
<table align="center">
   <tr>
    <td><h3>[wpv-post-title]</h3></td>
    <td><h4 style="color:black;padding-left:10px;">[wpv-post-taxonomy type="ip" format="name"]</h4></td>
  </tr>
  </table>
<div align="center" table-layout="fixed">
  <a class="info-buttons" href="[types field='cut-sheet-link' raw='true'][/types]" target="_blank" rel="noopener noreferrer">Cut Sheet</a>
  <a style="display: inline-block;" href="[types field='ies' raw='true'][/types]">[types field='ies-button' raw='true'][/types]</a>
  </div>

</div>
</div>

Thanks

#1914015

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok but within the View's loop where exactly you want to display the specific item?
- At the start of the loop
- at the end of the loop
- at the middle of the loop on specific index?

#1914661

At the middle of the loop on specific index.

#1918667

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

To target the specific loop index and display something:

Toolset Views/Blocks offers the shortcode [wpv-loop-index] that will return the current loop index within the views loop.
=> https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-loop-index

You can use this shortcode in conjunction with [wpv-conditional] shortcode.

For example - to display something on loop index 5:

[wpv-conditional if="( '[wpv-loop-index accumulate='false' pad='false' offset='0']' eq '5') "] 
something will be displayed on 5th loop instance
[/wpv-conditional]