SiteHelper
@SiteHelper
WordPress

ACF как включить обработчик true/false?

Здравствуйте!
Есть тема Newspaper, через плагин ACF в мета выведен параметр true/false (свитч да/нет).
Никак не хочет запускаться в виджет-блоке от newspaper. Проверка не работает.
Буду благодарен за любую помощь.
Само условие
<?php if( get_field('myfield') ): ?>	
	<?php // code ?>	
<?php endif; ?>

Код модуля
class td_module_16 extends td_module {
    function __construct($post, $module_atts = array()) {
        parent::__construct($post, $module_atts);
    }
    function render() {
        ob_start();
        $title_length = $this->get_shortcode_att('m16_tl');
        $excerpt_length = $this->get_shortcode_att('m16_el');
        $modified_date = $this->get_shortcode_att('show_modified_date');
        ?>
        <div class="<?php echo $this->get_module_classes();?>">
            <div class="item-details">
			    <div class="td-module-meta-info">
                    <?php echo $this->get_date($modified_date);?>
                </div>
                <?php echo $this->get_title($title_length);?>
            </div>
        </div>
        <?php return ob_get_clean();
    }
}

Код блока куда встраивается модуль
class td_block_21 extends td_block {
    static function cssMedia( $res_ctx ) {
        $res_ctx->load_font_settings( 'f_header' );
        $res_ctx->load_font_settings( 'f_ajax' );
        $res_ctx->load_font_settings( 'f_more' );
        $res_ctx->load_font_settings( 'm16f_title' );
        $res_ctx->load_font_settings( 'm16f_cat' );
        $res_ctx->load_font_settings( 'm16f_meta' );
        $res_ctx->load_font_settings( 'm16f_ex' );
    }
    public function get_custom_css() {
        $unique_block_class = $this->block_uid . '_rand';
        $compiled_css = '';
        $raw_css = '';
        $td_css_res_compiler = new td_css_res_compiler( $raw_css );
        $td_css_res_compiler->load_settings( __CLASS__ . '::cssMedia', $this->get_all_atts() );
        $compiled_css .= $td_css_res_compiler->compile_css();
        return $compiled_css;
    }
    function render($atts, $content = null) {
        parent::render($atts); // sets the live atts, $this->atts, $this->block_uid, $this->td_query (it runs the query)
        if (empty($td_column_number)) {
            $td_column_number = td_global::vc_get_column_number(); // get the column width of the block from the page builder API
        }
        $buffy = ''; //output buffer
        $buffy .= '<div class="' . $this->get_block_classes() . ' td-column-' . $td_column_number . '" ' . $this->get_block_html_atts() . '>';
		    $buffy .= $this->get_block_css();
		    $buffy .= $this->get_block_js();
            $buffy .= '<div class="td-block-title-wrap">';
                $buffy .= $this->get_block_title(); //get the block title
                $buffy .= $this->get_pull_down_filter(); //get the sub category filter for this block
            $buffy .= '</div>';
            $buffy .= '<div id=' . $this->block_uid . ' class="home_news td_block_inner">';
                $buffy .= $this->inner($this->td_query->posts); //inner content of the block
            $buffy .= '</div>';
            $buffy .= $this->get_block_pagination();
        $buffy .= '</div> <!-- ./block -->';
        return $buffy;
    }
    function inner($posts, $td_column_number = '') {
        $buffy = '';
        if (!empty($posts)) {
            foreach ($posts as $post) {
                $td_module_16 = new td_module_16($post, $this->get_all_atts());
                $buffy .= $td_module_16->render($post);
            }
        }
        return $buffy;
    }
}
  • Вопрос задан
  • 212 просмотров
Пригласить эксперта
Ответы на вопрос 1
azerphoenix
@azerphoenix
Java Software Engineer
Скорее всего, вы создали кастомное поле для определённой страницы. Вам либо нужно использовать ACF option page и в качестве второго аргумента передавать option или как другой вариант передать туда Id страницы,для которой создано это поле
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы