Skip Navigation

[Resolved] Displaying View using shortcode ids

This support ticket is created 3 years, 9 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.

Our next available supporter will start replying to tickets in about 1.21 hours from now. Thank you for your understanding.

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 13 replies, has 2 voices.

Last updated by AlimB3245 3 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#1683239
Screenshot 2020-07-01 11.45.59.png

Tell us what you are trying to do? I need to display a view using the format [wpv-view name="Fragrance With Notes" ids="18677"] where 18677 is the post id.. I've created Content Template and assigned it to nothing.. and created a view with the name of 'Fragrance With Notes' (screenshot attached to help you understand how it should look).. the Query is based on Post ID, I've set it to

Include only posts with IDs set by the View shortcode attribute "ids" eg. [wpv-view name="view-name" ids="1"]

I've also UNSELECTED "Don't include the current page in the query result"

I expected to see the fragrance in the post wherever I insert this but instead the view seems to take the details from the post where I place the short code.. you can see it in these two links

hidden link
hidden link

In both cases the POST TITLE of the same post where the shortcode was inserted is reflecting instead of the post id used in the short code.

Is there any documentation that you are following?https://toolset.com/documentation/user-guides/views/filtering-views-query-by-post-id/

Is there a similar example that we can see?

What is the link to your site? hidden link

#1683641

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Using Toolset Block View - at the moment, there is no feature to filter your block view using the shortcode attribute.

But the workaround would be:
- you should just save your block view and delete the block view from your page and then you should try to add "Fields and Text" block and switch to the "HTML" mode within the "Fields and Text" block.

Then, you should try to add your view using the "Add Field or View" icon as shows with the following screenshot: hidden link

and adjust the shortcode attribute or directly add the view's shortcode as given under and save the page:

[wpv-view name="fragrance-with-notes" ids="18677"] 

- Please adjust the view name if required.

I hope this workaround I shared help you to resolve your issue.

#1683745

Hi Minesh

Thanks for the update..:-)..

If you check in this support thread

https://toolset.com/forums/topic/design-pages-with-dynamic-content/

you will see that Waqar had created a similar view and used it the way I am trying to use here.. the only difference is that he created a view on a page and I am creating a view on a content template (without assigning to anything)

And when I tried the same thing with VIEWS (creating the query and then using the loop wizard) and then used the block editor I was able to use this in the shortcode.. I just thought that instead of views I should try out BLOCK EDITOR (the way Waqar did it) so I experimented with the view created in BLOCK EDITOR

Also this line confused me..

you should just save your block view and delete the block view
save my block view or delete it? I am not sure I understood this ...

Please do advise.

Regards,
Alim

#1683775

Minesh
Supporter

Languages: English (English )

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

So - let me try to explain again.

There are two ways you can create view:
1) Using Classic way
- As you can see Waqar already suggested to display the view using classic way [the shortcode way]
=> https://toolset.com/forums/topic/design-pages-with-dynamic-content/#post-1657173

[wpv-view name="Current Issue Cover" ids="123"]
 
[wpv-view name="Current Issue Editorspeak" issueeditorspeak="123"]
 
[wpv-view name="Current Issue Articles" issuearticle="123"]

As you can see with above examples, Using classic way, you have a way to pass the shortcode attribute.

2) Using Blocks
- When you create a view using blocks, there is not way to pass the shortcode attribude like you do with classic views.

So, the workaround is:
- Have you already created the view using blocks? If yes:
--- You should remove the block view "Fragrance With Notes" from your content template and save your content template.

Then,
- you should try to add "Fields and Text" block to your content template and switch to the "HTML" mode available with the "Fields and Text" block.
- you should try to add your view (which you created using blocks "Fragrance With Notes" ) using the "Add Field or View" icon as shown with the following screenshot: hidden link
- and adjust the shortcode attribute or directly add the view's shortcode as given under and save the page:

[wpv-view name="fragrance-with-notes" ids="18677"] 

Note: please make sure you added the related "Query Filter" to your view's "Query Filter" section.

Please let me know if you do not able to make it work. I would be happy to login to your site and fix it for you.

#1683789

HI Minesh

Sorry but I tried what you mentioned and I am still not able to understand the BLOCKS VIEW method.. I think I will stick to the Classic View as it's something I could manage..

But I am also confused about what you mentioned about Waqar.. he didn't do it the classic view method, in fact he made me do it using PAGES to add the view.. as you can see in this screenshot

hidden link

It's using the Block Editor in Pages that we managed to do this and then we just used the shortcode to get the post

Regards,
Alim

#1683791

Just in case there's some misunderstanding, let me clarify

I am fine with using the shortcode.. so I can use this format in the post where I want the view to apear..

[wpv-view name="fragrance-with-notes" ids="18677"]

but I just want to confirm if using the create VIEW in a content template or Page would work or not? It's worked using PAGE (https://toolset.com/forums/topic/design-pages-with-dynamic-content/#post-1657173) but am I doing something wrong using a content template..

Also the name attribute.. I was a bit confused.. when you create a view using the classic editor we have access to the slug field so we can have the name of the view.. but in the block editor when you create the view it's not the slug name but the Actual View Name (which was used in the Wagar's method).. so do I use the slug name of the view or the Actual Name of the view?

Regards,
Alim

#1683973

Minesh
Supporter

Languages: English (English )

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

Also the name attribute.. I was a bit confused.. when you create a view using the classic editor we have access to the slug field so we can have the name of the view.. but in the block editor when you create the view it's not the slug name but the Actual View Name (which was used in the Wagar's method).. so do I use the slug name of the view or the Actual Name of the view?
==>
You should use the view's slug name.

With content template as well the view you shared should work:

[wpv-view name="fragrance-with-notes" ids="18677"]

Can you please share problem URL where you want to display the above view and content template link where you want to add the above view and access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1684131

Minesh
Supporter

Languages: English (English )

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

You have done a big mistake. With the block view you created:
=> hidden link
- You have added the things to display outside the view's loop. You need to add whatever content you want to display within the view's loop.

So, I've moved the content you have added within the view's loop as you can see now:
=> => hidden link

And then created the following test page:
=> hidden link
- Where I've added the view you created with the "Field and Text" block as you can see with the following screenshot:
=> hidden link

When I display the test page on front-end, I can seen now view output the correct result:
=> hidden link

For the view slug query, I've checked and when I added the view with the view name - it just works fine, so you can use the view's name as well. Generally I suggested to use the slug because when I use the "Fields and Views" button to add the view the view is always generated with slug rather than name. And for the view created using block, I do not see any way to locate its slug.

[wpv-view name="Fragrance With Notes" ids="18677"]
#1684495
Screenshot 2020-07-02 11.05.13.png

Hi Minesh

Thanks for the update.. and the fix.. it works fine now..

and yes, I didn't realise that I had moved it out of the loop..

so basically we can make a view to use with shortcode using a block editor.. right?

I used the below shortcode by adding Shortcode block

[wpv-view name="Fragrance With Notes" ids="18677"]

where you had used the fields and text block method.. in this post..
hidden link

and you'll see that the shortcode option works like your method.. so I guess both methods work..

Anyways I need a small favour.. could you please remove one CONTAINER from the VIEW.. I didn't know how to remove it.. if you check the screenshot you will realise that there are 2 CONTAINER layer under the VIEW LOOP.. I need just one for styling.. but the other one I am not sure how to remove.

Do let me know once you are done so that I can close this ticket.

Thanks once again for your help. Have a nice day..:-)..

Regards,
Alim

#1684569

Minesh
Supporter

Languages: English (English )

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

so basically we can make a view to use with shortcode using a block editor.. right?
==>
Yes, you can able to display the view you created using block using the view's shortcode.

Anyways I need a small favour.. could you please remove one CONTAINER from the VIEW.. I didn't know how to remove it.. if you check the screenshot you will realise that there are 2 CONTAINER layer under the VIEW LOOP.. I need just one for styling.. but the other one I am not sure how to remove.
==>
OK - I've removed the another container block.

#1685973

Minesh
Supporter

Languages: English (English )

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

Can you please check and confirm the additional container is removed and issue is resolved 🙂

#1686023

Hi Minesh

Thanks..:-).. yes, the container issue was resolved..

Could you please let me know how you did this? So that I don't bother you each time I have such a request..;-)..

I assumed if I selected the container and removed block it would delete the content too.. and I couldn't find a way to drag it out of the existing container.. please advise.

Regards,
Alim

#1686041

Minesh
Supporter

Languages: English (English )

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

I've converted your existing container block (which contains the other blocks inside it) to reusable block. As you can see with the following screenshot: hidden link

And then removed your existing container block and again with "Add Block" button within the view's loop I've added the reusable block.

#1686203

My issue is resolved now. Thank you!

Thanks Minesh..:-)..

Have a nice day..:-)..

Regards,
Alim

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.