Running a long conditional on the wordpress loop to display certain posts

I'll try and keep this simple.

I need to write a conditional that allows the user to either have 3 posts from one CPT or 1 from each CPT displaying on the homepage.

I have 3 CPT's and 1 taxonomy in each one. Each taxonomy has 3 terms -> homeone, hometwo, homethree

these will be what the user selects to make that post appear on the homepage.

display post in the first loop | homeone = first loop
display post in the second loop | hometwo = second loop
display post in the third loop | homethree = thirdloop

So far to achieve wanted result I've written this but am yet to debug or test it as my knowledge of php is still lacking.

The website I'm working on the 3 images with text underneath are what I'm going to be changing


I would suggest using WP_Query to fine tune the query rather than using if statements and outputting the default wordpress loop.

Similar questions

Loop parent terms {display posts} AND loop child terms {display posts}
I am trying to loop through the category taxonomy and display the posts attached to each term, with a heading (the term name) separating each term's posts (and also display all the terms, even those that are not attached to any posts). Additionally, I need the child terms to be displayed as subheadings under their parent term's heading. For example...
setting featured image is not working while running script in background, works when running that script from browser
I have creted a script which will fetch content from one of my site and automatically create new post in my wordpress blog. When I am running that script from browser, its working really cool! post is being created, intended image is being set as featured image but when I am trying to run it from background or as a cron job, post is being created, ...
Is there any way to test if a function running only on plugin update is successfully running?
Is there any way to test if a function running only on plugin update is successfully running? Right now I am calling function if WP version present in configuration file is not same as plugin version's value in database and so testing by changing value of constant. But is there any other better approach?
Is there a plugin to display certain posts on certain pages?
On the homepage I want to display the latest 4 posts from the 'news' and 'events' category, whereas on the events page, I just want to display all posts in the 'events' category in WP's usual paginated form if there is a lot of them. Do you know of any plugin that handles this kind of rules based post generation? If not, what would be the best way ...
How to display a certain template element only for posts published within certain time range?
I recently migrated a blog from to Because I'm using Facebook comments, all the posts published before April 25 need to reference as the fb:comments href. I know how to display certain posts for my date range with this code: But can I manipulate this code to use at the template l...
How can I display all values of a custom field from posts with a certain value of another custom field or from certain post types?
I know the question is quite ambiguous. Let me explain: I have a page that lists all posts with a certain value of a custom field. (Eg.: The page Rentals lists all posts with the value rental of custom field offer_type ). I'd like to add a filtering option by city, so that only posts with a certain value of city custom field get displayed. For this...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.