I need a variable title on a view. f.ex. 'blogg' see (attachment)
I have a view with a query filter value as a shortcode like this:
[wpv-view name="view-name" wpvcategory="xxxx"]
I would like to use conditional statements to show titles:
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<section class="wpv-loop js-wpv-loop front-section cf">
[wpv-conditional if="( '[wpvcategory]' eq 'Blogg' )"]
<h3 class="blog-title">Blogg</h3>
[/wpv-conditional]
.... more
The problem with that conditional statement is that the show="single" double quotes break the if="..." double quotes, breaking the entire shortcode. You need to use single quotes for show='single'.
But I'm not sure about the purpose of your condition, because you are saying "if the post type label is not nothing then show it", but of course the post type label exists if you have a View iterating over posts. (If you are querying taxonomies or users then it will fail.)
I want to show the name of the post type (f.ex. portfolio) as a headline. I guess what the conditional statment is not used because all post type by defintion have a name 🙂
But this does not show the headline:
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<section id="front-section-two-portfolio" class="front-section cf">
<h3 class="blog-title">[wpv-post-type show="single"]</h3>
...more
The value of [wpv-post-type show="single"] is empty it should be f.ex. 'Portfolio'
OK, sorry, I see that you are using the shortcode within the Loop Editor but outside of the loop itself.
So it doesn't have the context of one of the posts from the query to know the post type.
If you want to create a heading with the post type, i.e. it should appear only once and not for every iteration of the loop, then I suggest you do something like this:
<wpv-loop>
[wpv-item index=1]
<h3>[wpv-post-type show="single"]</h3>
...your other loop stuff...
[wpv-item index=other]
...your other loop stuff...
</wpv-loop>
That way the heading is only shown for the first iteration of the loop.