[Support request] Adding extra fields to output

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Adding extra fields to output

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2779
    nancy
    Participant

    Hello-

    Thank you for the amazing layout. I have a custom post type that I am working with and I am wondering it there is an easy way to have it display some of my custom fields. As an example, I have a “star rating” in my custom post type and I would like to output it to the right of the title. Is this possible?

    Thank you very much.

    #2780
    nancy
    Participant

    I found this code myself in the forums:
    add_action( ‘wpsp_before_content’,’wpsp_add_custom_meta’ );
    function wpsp_add_custom_meta()
    {
    $meta = get_post_meta( get_the_ID(), ‘_your_custom_meta_key’, true );
    if ( isset( $meta ) && ” !== $meta )
    echo $meta;
    }

    and have updated it in the functions.php of wpshowposts folder. Is this correct? The values do not appear to be showing in my post list. I have also updated the meta key to my custom value.

    #2789
    Tom
    Keymaster

    Yes, you could do something like this:

    add_action( 'wpsp_before_content', 'tu_add_custom_meta' );
    function tu_add_custom_meta() {
        $meta = get_post_meta( get_the_ID(), '_your_custom_meta_key', true );
        if ( isset( $meta ) && '' !== $meta ) {
            echo $meta;
        }
    }

    It should be added in your child theme functions.php file, or using a plugin like this: https://en-ca.wordpress.org/plugins/code-snippets/

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