Hi,
another question:
I need to use custom fields for my posts. I am therefore using the ACF plugin and using the code to display the custom field ( the_field (“name_of_the_field”) ) works perfectly well for the modules. However I would like to show the custom fields on the blocks as well. According to the documentation eg block layout 7 is made from module layout 6. The field is shown on module 6 but not on block 7 => so I assume I need to enter the code for displaying the custom field somewhere else. Can you help pls. and as I am not familiar with php pls. guide me through.
Many thanks!
Christoph
Hi Lucian,
here is the modified code of td_module_6.php with 2 custom fields and 2 CSS selectors
<?php
class td_module_6 extends td_module {
function __construct($post) {
//run the parrent constructor
parent::__construct($post);
}
function render() {
ob_start();
?>
<div class="<?php echo $this->get_module_classes();?>" <?php echo $this->get_item_scope();?>>
<?php echo $this->get_image('td_100x75');?>
<div class="item-details">
<span id="datfei"><?php the_field('datum_feiertag'); ?></span><br/><span id="gueltigkeit"><?php the_field('gueltigkeit'); ?></span>
<?php echo $this->get_title();?>
<?php if (!empty($td_mod_single->td_post_theme_settings['td_subtitle'])) { ?>
<p class="td-post-sub-title"><?php echo $td_mod_single->td_post_theme_settings['td_subtitle'];?></p>
<?php } ?>
<div class="meta-info">
<?php if (td_util::get_option('tds_category_module_6') == 'yes') { echo $this->get_category(); }?>
<?php echo $this->get_author();?>
<?php echo $this->get_date();?>
<?php //echo $this->get_comments();?>
</div>
</div>
<?php echo $this->get_item_scope_meta();?>
</div>
<?php return ob_get_clean();
}
}
here are 2 links:
this is a category page using the module 6 (working fine):
this is a page using the block 7 in the sidebar (it would also not work if I add a VC block 7 in the content – already tried that) – you see that the CSS is there (black background) but no content…
regards
Christoph
You might try this
<?php echo $this->the_field('datum_feiertag'); ?>
I think there needs to be something there to say “get from this record” … vs just echoing the field unless the field applies to everything on the site.
That could be wrong… just a thought ….
I use ACF on one of my sites .. love it 🙂