Skip Navigation

[Resolved] Using same View with different Content Template

This support ticket is created 7 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
- 9:00 – 17:00 9:00 – 17:00 9:00 – 17:00 9:00 – 17:00 9:00 – 17:00 -
- - - - - - -

Supporter timezone: Europe/Athens (GMT+03:00)

This topic contains 9 replies, has 2 voices.

Last updated by rashedM 7 years, 7 months ago.

Assisted by: Konstantinos.

Author
Posts
#436833

Hi - is there an argument that can be added to a View shortcode to use a different Content Template?

Basically, the same View query but displaying the output using a different layout template.

#436923

Using wpv-attribute shortcode in a view, you can fetch an argument of the shortcode, where this view is inserted.

For example, inside a view's loop output, you can display a content template defined by wpv-attribute shortcode:

[wpv-post-body view_template='[wpv-attribute name="ct"]']

and then call this view from any page, using the desired ct argument, for example:

[wpv-view name="custom-view" ct="my-first-content-template"]

or

[wpv-view name="custom-view" ct="my-second-content-template"]

Please note that in this case, the ct argument should always be passed in wpv-view shortcode for this specific view and have a valid value (corresponding to an actual content template).

I hope that helps.

Regards,
Konstantinos

#437218

Thank you. Used the first line in the main View, and in an Archive page I used the second line; the whole page was rendered in text.

#437340

I am not sure I fully understand the way you are trying to use the View and the WordPress Archive.

In my example, the first shortcode should be entered in the View loop output and the second shortcode should be entered in a page that uses the View.

Could you please give me more information on what you are trying to achieve?

#437347

The intended use is in nested templates and/or archives, not only in pages. I am trying to use the same View but displayed using different content templates rather than creating the same View for every use whether in pages, archives, single, nested or not.

Child CPT
a. View to query all posts belongs to Parent CPT
a.1 Here I used the wpv-attribute inside the wpv-loop

Parent CPT
b. Single Content Template
b.1 Nested Template called "One": listing Child CPT using ct="One"

c. WordPress Archives
c.1 Nested Template called "Tow": listing Child CPT using ct="Two"

The above method displayed the output in text disregarding the actual template it should have used to display the data.

Thank you.

#438414

Ping.

#438418

Sorry for the delayed response.

In order to be sure that I understand correctly what you want to achieve, I would like to request temporary admin access to your site.
You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Please, also include some hints on where I can find the resources that you are describing in the previous comment (pages, views, content templates, archives, etc).

#438489

Thank you for the additional information.
Though, I still have some concerns about your setup and would be better to check step by step.

You said that you are have a View that lists both parents and children, including a query filter by parent post type. Did you check that this work properly, even without the idea of reusing the content template?

You are also trying to reuse the same content template for both children and parent entries. Do they share the same structure and fields? Otherwise, there is no point in trying to to do that.

As you cannot provide admin credentials, I would kindly ask you to provide a duplicator package, so I can take a deeper look in your local site.

Duplicator is a free plugin (http://wordpress.org/plugins/duplicator/) and, in case that you haven't used before, please follow the steps:
- From WordPress plugin page, look for "Duplicator" and install it
- Once installed, you get a new main menu "Duplicator"
- Chose "Packages"
- Click on the first button you find in the toolbar on the right ("Create Package")
- Give it a name or leave it as is
- Click on "Create Package Set"
- Wait until the package is ready
- Click on "Installer", then on "Package": the first one is just a php script, the second one is a zip file containing everything you need
- Send me both files (you probably want to use DropBox, Google Drive, or similar services, as the snapshot file will be quite big)

I will set the next reply as a private, so you can provide me the information securely.

#438506

I followed the exact steps of this last setup and it is working for me as expected.

The single item content template displays the content using "content-template-one" and each item in archive displays the content using "content-template-two".

Could you describe me the issue that you are facing and in which step this occurs?

#438874

All good, thank you.

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