Skip Navigation

[Resuelto] Is it possible to inject posts from a different CPT randomly in a loop?

This support ticket is created hace 8 años, 3 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Etiquetado: 

Este tema contiene 3 respuestas, tiene 2 mensajes.

Última actualización por Minesh hace 8 años, 3 meses.

Asistido por: Minesh.

Autor
Mensajes
#367070

Jay

I have a digital marketplace site with various CPT's (ie: general for sale, properties, vehicles, etc).

Since users post and create listings for free (via CRED), the model for revenue comes instead from Sponsors (whom I also have a CPT created for) who pay monthly to create a single listing which advertises their business and it's (hopefully) injected into the site's views archive loops that I have setup (not WordPress archives).

So is it possible to have a Sponsor create a sponsor ad, and then have that post link along with all other Sponsor created post links be randomly injected automatically into my various view post archives? And by randomly, I mean in random order and at random intervals. Something ideally preset.

Hope that makes sense. Any insight would be much appreciated!

#367084

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I would like to have more detail on this for better understanding.

As I understand you have page where you have added your archive view and with that view you want to show loggedin user created ads listing first and after that you want to list ads created by other users, right?

Basically, you want to give priority to loggedin user created listing should display first and after that other users listing.

#367875

Jay

Hi Minesh!

Thank you for your response however, I believe I explained my scenario poorly. I just didn't want to ask a question with long winded details if they weren't necessary to you. Let me try it again in more detail.

Here is an outline of my site relationship structure:

Listings (Parent CPT)

-> Classifieds - (Child of Listings CPT)
---> Classifieds Categories - (Taxonomy)
-----> Antiques & Collectibles - (Tax Term)
-----> Clothing & Footwear - (Tax Term)
-----> etc. etc. - (Rest of Tax Terms)

-> Properties - (Child of Listings CPT)
---> Property Categories - (Taxonomy)
-----> Single Family Homes - (Tax Term)
-----> Multi-Family Homes - (Tax Term)
-----> etc. etc. - (Rest of Tax Terms)

-> Vehicles - (Child of Listings CPT)
---> Vehicle Categories - (Taxonomy)
-----> Cars & Trucks - (Tax Term)
-----> Motorcycles & Scooters - (Tax Term)
-----> etc. etc. - (Rest of Tax Terms)

-> Jobs - (Child of Listings CPT)
---> Job Categories - (Taxonomy)
-----> Construction & Trades - (Tax Term)
-----> Automotive & Mechanics - (Tax Term)
-----> etc. etc. - (Rest of Tax Terms)

Users that visit the site can view all post listings of any type without registering. Users only need to register if they want to create a new listing - which is free of charge for them to do via CRED front end forms. This is all working flawlessly.

As you can see, I have a "Listings" parent CPT, which has the Post Types 'Classifieds', 'Properties', 'Vehicles', and 'Jobs' set as children. Each of the 4 child CPTs has a taxonomy for categories to divide up the posts in each given CPT logically for the user to view in Taxonomy Term Archives.

The method I'm using for users to view those Taxonomy Term Archives is by using a view where I pass the url value in a ShortCode attribute (ie: [wpv-view name="view-name" wpvcategory="xxxx"]). I have a page created for each Taxonomy Term Archives where I insert this view. Then I use direct links in my main site navigation for users to visit these Term Archive pages. I end up with the following URL example for every tax term on my site:

ie: enlace oculto

Now that you have a better idea of my site structure and approach, this is where the Sponsor listings come in, and what I'm ultimately trying to achieve.

I should mention that this site is for a small geographic area in the USA (just a single County in my State). Since the site is free for regular users to view and post in any category, the revenue stream comes from Sponsor Ads.

These "Sponsor Ads" are created by small business owners in the area wishing to create a "Sponsor Ad" for their business and have it show up in the Taxonomy Term Archives at preset intervals for general users to see.

Since all general users of the site are in the same geographic area as the Sponsor's small business, having users see their "Sponsor Ad" in the Term Archives becomes very valuable to them as they know all general users are in the same area as their business. Therefore, business Sponsors pay a fee to create a single "Sponsor Ad" that lasts for 1 month and shows up in the various Taxonomy Term Archives at random intervals.

To illustrate an example:

A small business pays a fee, and then can create a single Sponsor Ad for their business to show up in the archives.

A general user is viewing the site, and they are looking at the following Taxonomy Term Archive page: enlace oculto

The general user sees a list of post links created under the Taxonomy Term, Cars & Trucks.

As they scroll down that archive list of post links in the Cars & Trucks category, every 5 posts (or whatever interval), a business Sponsor Ad is injected in the loop. So they'd end up seeing:

2004 Toyota Camry
2010 Infinity G37 Coupe
2013 Audi A5 Cabriolet
2012 BMW X6 XDrive 35i
2001 Equinox Crossover
SPONSOR: Acme Auto Parts
2008 CTS-V Sport Coupe
2010 Jeep Wrangler
2012 Range Rover
2014 Mercedes Benz SL550
2008 Escalade EXT
SPONSOR: Acme Family Restaurant
2014 Acura RLX Elite Hybrid
2007 Chevy Cobalt
etc.

The example above is obviously just for the "Vehicles" CPT in the "Cars & Trucks" Taxonomy Term. I'd need to have the same sponsor ads injected into all Term Archives for all listings. I have already created a Sponsor CPT. But I'm not sure if I make it a child of "Listings" or not - or how the relationships would work between CPTs. I know I don't technically need the parent "Listings" CPT currently but thought I might if I was to add sponsors.

So in a nutshell, I'm wondering if it's possible for these Sponsor Ads to be injected into all Taxonomy Term Archive pages at random intervals using Toolset? If not, could you possible suggest an alternate solution to investigate?

I hope that all makes sense. Thank you so much for any insight you may have Minesh! 🙂

#368033

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Thank you for brief description to explain your problem and I totally understand it.

With views you can display "index" specific items. And to display sponsor ads you should write a custom code that will return a single ad when you call custom code.

So considering your example, with each 5th record following code will dispaly ads:

<wpv-loop>
    [wpv-item index=5]
        [your-custom-shortcode-to-display-ads]
         Meta HTML to be output all other items returned by the loop       

      [wpv-item index=other]
      Meta HTML to be output all other items returned by the loop    
 </wpv-loop>

Please refer to following link for more info:
https://toolset.com/documentation/views-shortcodes/#wpv-item
https://toolset.com/documentation/user-guides/view-layouts-101/

I hope this solution will help you to achieve what you are looking for.

Este ticket ya está cerrado. Si eres cliente de Toolset y necesitas ayuda relacionada, abre un nuevo ticket de soporte.