[Resolved] Header Element Template Tag Issue

Home Forums Support [Resolved] Header Element Template Tag Issue

Home Forums Support Header Element Template Tag Issue

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #918076
    Patrick

    Hello, I’m trying to whip up a page header for a custom post type. I’m a writer and I’m putting together a portfolio. I created a new custom post type “sample” and custom field with PODS, and I’d like to display one of the custom fields, “specialty,” in the header. However, instead of the selected specialty of the sample, the header displays “Array.” I’m sure it’s something simple that I’m missing, but do you know what I might be doing wrong? Thanks very much.

    #918077
    Leo
    Staff
    Customer Support

    Hi there,

    Just to make sure, this is what you are trying to do?
    https://docs.generatepress.com/article/header-element-template-tags/#custom_field-name

    Can you make sure everything is done correctly, and link us to the site in question if it doesn’t work?

    Let me know πŸ™‚

    #918079
    Patrick

    Hi Leo, yes, that’s right. It’s on a dev site that’s password protected. How can I get you the info?

    #918091
    Leo
    Staff
    Customer Support

    You can send the dashboard access using Account Issue here:
    https://generatepress.com/contact/

    Please include the following information:
    – The URL of this topic.
    – Login URL.
    – Username and password.

    #919055
    Patrick

    Thanks Leo. Account Issue sent.

    #919725
    Tom
    Lead Developer
    Lead Developer

    This likely means the custom field is outputting an array, which our template tag isn’t built for.

    Instead, you’ll want to build a shortcode:

    add_shortcode( 'your_shortcode_name', function() {
        ob_start();
            
        $custom_field = get_post_meta( get_the_ID(), 'your_custom_field', true );
    
        foreach ( $custom_field as $field ) {
            echo $field;
        }
    
        return ob_get_clean();
    } );
    #919837
    Patrick

    Thanks Tom. I’ll give it a shot and let you know how it goes.

    #922157
    Patrick

    Hi folks, the problem was the fields I created were bidirectional relationship fields. I changed them to simple plain text and the fields now display properly.

    #922185
    Leo
    Staff
    Customer Support

    Awesome. Thanks for sharing the solution!

    So the settings are within PODs plugin I assume?

    Just want to know for future reference πŸ™‚

    #923894
    Patrick

    Leo, that’s right. I created custom taxonomies and linked them with custom fields. Kind of a bummer they can’t be linked but I kept the categories so I can still organize my samples in a couple different ways.

    #924143
    Leo
    Staff
    Customer Support

    Thanks for reporting back!

    I’m sure it will help the next user πŸ™‚

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.