Okay
  Public Ticket #2852260
editting post template on kalium child theme
Closed

Comments

  •  1
    Sutton585 started the conversation

    I activated the child theme so that I can adjust how posts display. I want to have the text output of my custom field to display in place of the post's publish date. Unfortuantely, I can't find a file that outlines what a standard post is sopposed to consist of, which means I can't find where it calls for the post date variable so I can replace it with a call to the data from my custom field.

    Is there a page in Kalium proper that I should copy into the child theme directory and make adjustments that way? If so, I'd love an assist on finding it; I'm a little new to wordpress child themes.

    Thanks for your time.

  • [deleted] replied

    Hi,

    Kalium uses hooks approach when it comes replacing the segments of certain content types. In this case, in blog posts archive the data is structured this way:

    medium
    (view large image)

    So if you want to disable post date and add your own code, add this code in functions.php (without needing to replace theme files and update proof):

    add_action( 'init', function() {
        remove_action( 'kalium_blog_loop_post_details', 'kalium_blog_post_date', 30 );
        add_action( 'kalium_blog_loop_post_details', 'my_custom_field_content', 30 );
    } );
    function my_custom_field_content() {
        echo "My custom field content goes here";
    }
    The same applies for single post, with different attached hook name and priority:

    medium
    (view large image)

    add_action( 'init', function() {
        remove_action( 'kalium_blog_single_post_meta', 'kalium_blog_post_date', 10 );
        add_action( 'kalium_blog_single_post_meta', 'my_custom_field_content', 10 );
    } );

    So the entire code would be:

    add_action( 'init', function() {
        // Blog posts archive
        remove_action( 'kalium_blog_loop_post_details', 'kalium_blog_post_date', 30 );
        add_action( 'kalium_blog_loop_post_details', 'my_custom_field_content', 30 );
        
        // Single post
        remove_action( 'kalium_blog_single_post_meta', 'kalium_blog_post_date', 10 );
        add_action( 'kalium_blog_single_post_meta', 'my_custom_field_content', 10 );
    } );
    function my_custom_field_content() {
        echo "My custom field content goes here";
    }
    

    I hope this helps you.