I have an advanced custom field group, and inside the group and inside the group are a few fields and one select field in where the user selects a category. I want to output onto the page based on what category has been chosen.
Here is the code I was trying:
<?php
$limit = get_option('posts_per_page');
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('post_type=Specialist_post&showposts=' . $limit . '&paged=' . $paged);
$wp_query->is_archive = true; $wp_query->is_home = false;
if(have_posts()) :
while(have_posts()) :
the_post();
if(get_field('category') == "1402")
{ ?>
<div class="row wheelsspecial">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<h3><?php the_field('company_name'); ?></h3>
<p><?php the_field('brief_description'); ?></p>
<p><?php the_field('contact_number'); ?></p>
<a href=""><?php the_field('website_address'); ?></a><br />
<a href="mailto:"><?php the_field('email'); ?></a>
<?php } else if (get_field('category') == "1403") {?>
<div class="row tuningspecial">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<h3><?php the_field('company_name'); ?></h3>
<p><?php the_field('brief_description'); ?></p>
<p><?php the_field('contact_number'); ?></p>
<a href=""><?php the_field('website_address'); ?></a><br />
<a href="mailto:"><?php the_field('email'); ?></a>
<?php } ?>
<?php
endwhile;
else:
?>
Oops, there are no posts.
<?php
endif;
?>
This now outputs nothing, if i echo the field category its returning 1403, so i would think it at least outputs the else if, maybe this whole code design is wrong. Essentially i want to print different into different divs based on the category selected.
echoon any ofthe_feild()methods. Is this intentional? - worldofjrthe_field()equivalent toget_field()? You could useecho get_field('company_name');as this seems to be returning OK. - worldofjr