[Resolved] Custom Fields

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Custom Fields

Tagged: 

Viewing 7 posts - 31 through 37 (of 37 total)
  • Author
    Posts
  • #13247
    Cris
    Participant

    Perfect!! I have learned a lot with this. Thanks a lot Tom!!!

    I have proven that without ‘ . $term->slug . ‘ it also works.

    #13272
    Tom
    Keymaster

    Awesome! Glad I could help 🙂

    #13306
    sparkle
    Participant

    hi tom, is there a step by step somewhere for getting custom field content to display in a list (or ultimately in a carousel)? i have three custom fields in my cpt (cptui/acfpro) and i put this into my functions file, but am unsure how to ‘just hook them’ to get them into my list and ultimately to display as the carousel. [edited for clarity and to add when i put the below code in my functions file, i get a database error, too.]

     
    add_action( 'wpsp_before_content','wpsp_add_custom_meta' );
    function wpsp_add_custom_meta()
    {
        $meta = get_post_meta( get_the_ID(), 'st-headline', true );
        if ( isset( $meta ) && '' !== $meta )
            echo $meta;
    }
    
    add_action( 'wpsp_before_content','wpsp_add_custom_meta' );
    function wpsp_add_custom_meta()
    {
        $meta = get_post_meta( get_the_ID(), 'short_testimonial', true );
        if ( isset( $meta ) && '' !== $meta )
            echo $meta;
    }
    
    add_action( 'wpsp_before_content','wpsp_add_custom_meta' );
    function wpsp_add_custom_meta()
    {
        $meta = get_post_meta( get_the_ID(), 'st-attribution', true );
        if ( isset( $meta ) && '' !== $meta )
            echo $meta;
    }
    • This reply was modified 5 months, 3 weeks ago by sparkle.
    #13346
    Tom
    Keymaster

    That code looks like it should work, although you could wrap them all into one function.

    What’s the error you’re getting?

    #17796
    Austin
    Participant

    Where do I put this PHP?

    #17804
    Austin
    Participant

    I tried adding it as a hook element but I must be doing it wrong.

    • This reply was modified 5 days, 12 hours ago by Austin. Reason: duplicate
    #17825
    Tom
    Keymaster

    You should use one of these methods: https://docs.wpshowposts.com/article/adding-php/

Viewing 7 posts - 31 through 37 (of 37 total)
  • You must be logged in to reply to this topic.