Support

Account

Home Forums General Issues how to load custom single.php based on field type?

Helping

how to load custom single.php based on field type?

  • Hi I have a blog where the categories are news, events and inspiration. These categories are selected using radio buttons on acf. I want to load news on single-news.php while events on single-events.php and inspiration on single-inspiration.php

    is it possible to use the acf fields to do this?
    I have came across this code with wordpress default categories to load custom single.php s

    <?php
      $post = $wp_query->post;
    
      if (in_category('1')) {
          include(TEMPLATEPATH.'/single1.php');
      } elseif (in_category('2')) {
          include(TEMPLATEPATH.'/single2.php');
      } else {
          include(TEMPLATEPATH.'/single_default.php');
      }
    ?>

    what can be used instead of the ‘in_category’ while using acf?

    thanks guys.

  • Hi,
    you could use the following plugin
    http://www.advancedcustomfields.com/add-ons/taxonomy-field/
    to display on ACF a radio button with your 3 catégories, the post will get attached to the selectedi categorie, that way your code will still work.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘how to load custom single.php based on field type?’ is closed to new replies.