Quantcast
Channel: Toolset » All Posts
Viewing all articles
Browse latest Browse all 20145

Create Custom Class for Query on Selected Single Post

$
0
0

I'm not sure about the title, but here is what I am doing and would like to accomplish.

1) I have a single custom post type on a page (CPT is project. URL is /project/project-1/)

2) At the bottom of the page I have a view that takes a view template and loops through all the custom post type – INCLUDING the one above. That works well by creating a view and unchecking the "Don't include current page in query result." So I end up with a list like.

<div class="selected">Project 1</div>
<div class="selected">Project 2</div>
<div class="selected">Project 3</div>

3) I would like to apply a custom class to the project (project-1) as it is listed in the projects below. A kind of "Selected" class or something.

My div is is pretty simple. <div class="item"> for the projects below that are not the current project. I would like to make the curent project says <div class="selected">

So it would be

 
<div class="selected">Project 1</div>
<div class="item">Project 2</div>
<div class="item">Project 3</div>

POSSIBLE:
I was thinking I could do this with conditional statements, in particular post attributes:
http://wp-types.com/documentation/user-guides/conditional-html-output-in-views/#Checking other post attributes.

I am hoping to use one of the view shortcodes (http://wp-types.com/documentation/views-shortcodes/) and do a conditional check for the URL.. but I can't seem to get that working.

This is what I have on the individual view template it loops through.

[wpv-if evaluate="'[wpv-post-url]' = '[wpv-post-url]'"]
    <div class="selected"> 
		[wpv-post-link]
	</div>
[/wpv-if]

[wpv-if evaluate="'[wpv-post-url]' = '![wpv-post-url]'"]
    <div class="item"> 
		[wpv-post-link]
	</div>
[/wpv-if]

That just makes everything "selected". Any thoughts on how I might write this conditional statement? Or if I need to put the conditional statement in the loop instead and crate a second selected view template? Just let me know what you think a good solution to this would be with views.


Viewing all articles
Browse latest Browse all 20145

Trending Articles