I have a website which is about local types of foods and drinks. On the website, businesses can create a user and via the relationship field - add foods and drinks they offer.
The relationship field
'resturant' is displayed at
/wp-admin/profile.php for logged in users.
Foods and drinks pages:
website.com/food/ website.com/food/cherry-pie/ website.com/food/pancakes/ website.com/food/cookies/ website.com/drinks/ website.com/drinks/lemonade/ website.com/drinks/soda/ website.com/drinks/water/
Three registered users:
website.com/author/resturant-cuppa-joes/ website.com/author/resturant-mclovin/ website.com/author/resturant-hotcup/
User Resturant Cuppa Joe's and Resturant MClovin have for example added Cherry Pie as one of the meals they offer. User Resturant Hotcup have not. When someone visits the page
website.com/food/cherry-pie/I want Resturant Cuppa Joe's and Resturant MClovin to be featured there, and not Resturant Hotcup.
In page.php I have the following code:
<?php while ( have_posts() ) : the_post(); ?> <h2>Resturants</h2> <?php $resturants = get_users(array( // Changed from get_posts 'meta_query' => array( array( 'key' => 'resturant', // name of custom field 'value' => '"' . get_the_ID() . '"', 'compare' => 'LIKE' ) ) )); ?> <?php if( $resturants ): ?> <ul> <?php foreach( $resturants as $resturant ): ?> <li> <a href="<?php echo get_permalink( $resturant->ID ); ?>"><?php echo get_the_title( $resturant->ID ); ?></a> </li> <?php endforeach; ?> </ul> <?php endif; ?> <?php endwhile; ?>
Used the sample at advancedcustomfields.com, changed
Something seems to be right - I get a list with two links, but the links point to the start page.
What am I doing wrong?