Skip Navigation

[Resolved] Content based on url (subdomain)

This support ticket is created 7 years, 6 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 2.38 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by Walter Kamer 7 years, 6 months ago.

Assisted by: Nigel.

Author
Posts
#442201

Hello,

What I trying to do is the following:

I want to created a conditional output based on the subdomain entered and use that in a template page, so

if 'sub1.mydomain.com' is entered I want to display all the myproducts (CPT) that has the custom field subdomain = 'sub1' set.

Or I think about put something in the .htaccess to redirect all the subdomain with a variable after it, eg.

'sub1.mydomain.com' redirect 'sub1.mydomain.com/?subdomain=sub1'

Hope someone has some suggestions for me.

#442593

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Walter

Can I clarify what you are asking.

I'm not sure whether you are talking about users visiting a url such as sub1.mydomain.com and having that display all of a certain CPT that have a custom field 'subdomain' set with the value 'sub1'.

In which case you are talking about a multisite installation?

Or have I misunderstood?

#442708

Hello Nigel,

I'm not using a Multisite installation, it is based on the plugin 'Page as Subdomain'. In that way I can access a single page through a subdomain. Eg. hidden link can be accessed through sub1.mydomain.com.

When accessing that page I want to display content that is based on the subdomain (orginal the slug of the page). So my view needs an input variable that is filled by the subdomain/slug name.

E.g. the template view on the page:

[wpv-view name="all products based on subdomain" mysubdomain="sub1"]

Hoping this will clear my question.

#443056

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Walter

I'm not familiar with the plugin, but if all it is doing is mapping pages to subdomains, hopefully the page slug is still available.

You can refer to that with the shortcode [wpv-post-slug] (https://toolset.com/documentation/views-shortcodes/#wpv-post-slug).

So you should be able to re-write your view shortcode like so:

[wpv-view name='all products based on subdomain' mysubdomain='[wpv-post-slug]']
#443445

Thanks Nigel,

Your solution worked for me! De slug is still available when entering the page by subdomain.

I defined 'mysubdomain' in the query filter as a view variable an can use it that way.

Thanks for the support!

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