Notice: These forums are now retired and closed. For active support, please Submit a Ticket or visit our official WordPress.org community pages.
Kadence Theme | Kadence Blocks | Starter Templates | WooCommerce Email Designer | Ascend | Virtue | Pinnacle

Displaying custom fields using hooks

Home / Forums / Virtue Theme / Displaying custom fields using hooks

This topic is: Resolved
[Resolved]
Posted in: Virtue Theme
March 20, 2016 at 9:23 pm

Hi,

After being away from my website for a little while I downloaded the latest update to Virtue and saw that my homepage broke a bit. I’ve figured out that one of the template files I had edited has been updated and so now the changes I made to it aren’t appearing. Given that it’s poor practice to edit template files I’m not bothered that I need to fix this, but given I’m still learning this side of things I could use your help.

So, I’ve been trying to have a custom field display at the after the titles of the blog posts on my homepage. I tried copying and modifying some code Ben had given me earlier in my functions.php file, but it’s not working (in fact it keeps my site from loading at all). Here’s the code—could you tell me what’s wrong with it?

add_action( 'kadence_post_mini_excerpt_header', 'kt_add_custom_field', 5 );

function kt_add_custom_field() {

global $post;
echo '<div class="subtitle">'.get_post_meta( $post->ID, 'wpcf-subtitle', true ).'</div>';
}

Thanks for your help.

-Adam

P.S. I’ve noticed not all the templates have the ‘do_action()’ code that allows you to hook code into. Are there other ways of hooking in code?

  • The forum ‘Virtue Theme’ is closed to new topics and replies.