Can’t get option page custom fields on custom taxonomy archive page

I created options page using ACF and created custom taxonomy for posts and categories. I added to my header get_field for getting the logo and it’s working fine on most of the page..

On the custom taxonomy category page i get no data.. I tried to var_dump
and print_r and whatever.. It just doesn’t get anything and i couldn’t find answer on Google..

Read More

Here are my codes-

header.php

    <?php
        if (get_field('konimhakol_logo', 'options')) {
            $site_logo = get_field('konimhakol_logo', 'options');
            echo '<a href="'. get_bloginfo('url') .'" title="'. get_bloginfo('name') .'"><img src="'. $site_logo['url'] .'" alt="'. $site_logo['title'] .'"></a>';
        }
    ?>

functions.php

function create_businesses_post_type() {
    register_post_type('kh_businesses',
        array(
            'labels' => array(
                'name' => __('עסקים'),
                'singular_name' => __('עסק'),
                'add_new' => __('הוסף עסק')
            ),
            'menu_icon' => 'dashicons-admin-home',
            'taxonomies' => array('category', 'post_tag'),
            'supports' => array('title', 'editor', 'thumbnail', 'custom-fields'),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'businesses'),
        )
    );
}
add_action( 'init', 'create_businesses_post_type' );

// Add Businesses Post Type to Archives
function archives_add_custom_types($query) {
  if(is_category() || is_tag() && empty($query->query_vars['suppress_filters'])) {
    $query->set('post_type', array('kh_businesses'));
      return $query;
    }
}
add_filter( 'pre_get_posts', 'archives_add_custom_types' );

This is my Homepage and this is the Archive page

I’m so frustrated.. Thanks in advance

Related posts

2 comments

  1. Ok i found the problem!
    For getting the posts under the new categories i have added this code to my functions.php file-

    // Add Businesses Post Type to Archives
    function archives_add_custom_types($query) {
      if(is_category() || is_tag() && empty($query->query_vars['suppress_filters'])) {
        $query->set('post_type', array('kh_businesses'));
          return $query;
        }
    }
    add_filter( 'pre_get_posts', 'archives_add_custom_types' );
    

    But when i delete it, the header comes back but then there are no posts under my Business categories…

Comments are closed.