Support » Theme: Virtue » Adding Child Theme, Custom Post Type, Custom Fields

  • I have created a Custom Post Type, named Resources.
    I have added custom fields to Resources with Advanced Custom Fields.
    I have created /single-resource.php and /templates/content-single-resource.php in my child theme.
    However … I cannot seem to track down precisely where in these files (or elsewhere in a child theme) where I should make modifications to output my custom field content.

    Are there additional Parent Theme resources I need to duplicate? An atypical way of outputting custom content?

    Much thanks

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter craigtommola


    PS … Every time I try to add content to /templates/content-single-resource.php, I get this:
    “The site is experiencing technical difficulties.”

    Thread Starter craigtommola


    PPS … throughout the theme, you’ve misspelled “summary”
    $summery = 'full';

    When using advanced custom fields you should see which PHP calls to add to get those fields to output. Can you tell me what you are adding? Have you talked with Advanced custom fields?

    What content are you adding to the file? Can you send me the file code, that error usually means you have a markup error in your code.

    Thanks for the note on summary, I am in the process of a complete rewrite of virtue and that will be changed.


    Thread Starter craigtommola


    I was able to add content after I created a new div.
    I have spoken to ACF. The most recent question being:

    Ok – this is puzzling … how come this works:
    <li><?php $facebook= the_field('facebook'); if ($facebook != '') {echo $facebook; } ?></li>

    But not this:

    	$facebook= the_field('facebook');
    	if ($facebook != '') {
    			echo "<li><a href=\"".$facebook."\" class=\"fab\">".$facebook."</a><li>";
    Thread Starter craigtommola


    Got it to work like this:

    <?php if( get_field('facebook') ): ?>
    <a href="<?php the_field('facebook'); ?>"><li><?php the_field('facebook'); ?></li></a>
    <?php endif; ?>
    Thread Starter craigtommola


    Since you’ve moved all the post content into hooks, it makes it especially difficult to make custom post types and have unique output and formatting. Perhaps moreso in a child theme.

    For example, I have the custom post type Resources. On the Resources “single” page I want to remove the Author and Comment count. And include the featured image.

    Generally in child theming, I’d duplicate the single, perhaps a template-part, and customize. But all the pieces are separated into the /lib/template_hooks/post-hooks.php

    How do you recommend I customize a custom post type in a child theme of Virtue?

    You can do this with hooks in your child theme for example:

    add_action('init', 'custom_child_init');
    function custom_child_init() {
    remove_action( 'virtue_single_post_after', 'virtue_post_authorbox', 20 );
    add_action( 'virtue_single_post_after', 'virtue_post_authorbox_only_posts', 20 );
    function virtue_post_authorbox_only_posts() {
    if ( get_post_type( get_the_ID() ) == 'post' ) {

    That unhooks the author box from the post footer hook and then rehooks the author box back in only for the post type “post”.

    Usually though if you have a custom post type you don’t want anything from the blog post type since the blog is set up so differently so in your custom template you would not add any blog post type actions, instead you can either use your own actions or simply add in the content you want to use.

    Let’s say for example I want the template to output the title without outputting the metadata which runs through the virtue_single_post_header hook.

    In your custom post type template you can just add the_title(); function

    echo '<h1 class="entry-title">';
    echo '</h1>';

    Re: your earlier mention of rewriting Virtue – here’s a thought … regarding the “homepage” style, I suggest attaching those configurations to a “homepage page template” as opposed to “is_front_page()” then you can build multiple versions, or replace your homepage without developing the content live.

    Also – review the default design settings for ADA compliant contrast (specifically in the default “icon boxes”)

    Thread Starter craigtommola


    So … those above comments were also me, just a diff login. Anyway… I have a custom post type with custom fields. I’m outputting something to this affect:

    <h1><?php the_title(); ?></h1>
    <?php the_content(); ?>
    <div class=”resource-contact”>(ACF output of contact info)</div>
    <div class=”resource-social”>(ACF output of social media links)</div>

    I like the automatic “related posts” it’s picking up from my custom post type. However, it appears to be hooked to <?php the_content(); ?> and is therefore appearing between the post content and my ACF output.

    How might I “move” the related posts to, say the <footer class=”single-footer”> for example?

    I like the automatic “related posts” it’s picking up from my custom post type

    That isn’t from the theme, likely you are using jetpack?

    Check out this post:

    Let me know,


Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Adding Child Theme, Custom Post Type, Custom Fields’ is closed to new replies.