ACF Relationship Query
So this was a tricky one to wrap my head around, just because the logic makes sense, but is difficult to word.
So basically what I wanted to do was create a new Custom Post Type, which would have a selection list of all the published posts for you to be able to select to apply that Custom Post to, and then for the Custom Post to show up on whatever pages where selected.
I hit a snag with something I thought would work, but didn’t and then had a brainwave this morning. And here was the solution for anyone interested:
<?php $special_offers = get_posts(array( 'post_type' => 'special_offers', 'meta_query' => array( array( 'key' => 'applies_to', // name of custom field 'value' => '"' . get_the_ID() . '"', 'compare' => 'LIKE' ) ) )); if( $special_offers ): foreach( $special_offers as $offer ): // Do something to display the articles. Each article is a WP_Post object. echo "<div class='special_offer'><h3>"; echo $offer->post_title; // The post title echo "</h3><span class='offer_text'>"; echo $offer->post_content; // The post content echo "</span></div>"; endforeach; endif; ?>
- Where Is the Best Place for Social Media Icons?
- Tips for Creating a Great Logo for Your Brand
- Hiring a Web Designer – Watch Out for These Red Flags
- How to Use Effective Branding On Your Business Emails
- How to build an effective website for your business
- How to Create a Brand Community
- How to Pick the Right Microsoft Office Package
- Self-employment and tax
- 5 Reasons Brand Consistency is So Important
- How to Choose the Best Hosting Plan for Your Business
- Displaying WordPress childpages with thumbnails
- Pagination with a custom wp_query
- Self Employment Adventures
- Displaying Custom Posts by Taxonomy Order With Taxonomy Titles
- Advanced ACF Relationship Query
- ACF Relationship Query
- Custom post type orderby menu_order not working?
- How to add an Admin user to a WordPress install via FTP
- Christmas approaches
- Shadow of the Colossus
- SJC Snare Drum Painting #02
- The Sho Exhibition
- Art Show!
- Adventure Cat
- Artshow Robot
- Dead Nyan Cat
- SJC Snare drum painting
- The Hype Theory Comic
- Barriers of entry
- My first mural
- SJC snare drum painting
- Weeks go by
- Wacom Shortcuts
- You are experience technical difficulties
- 3D Grass Render
- The black hole of work!
- Blwyddwyn Newydd Dda!