[Support request] How To Create Feature (Similar to Feature Image)

Home Forums Support [Support request] How To Create Feature (Similar to Feature Image)

Home Forums Support How To Create Feature (Similar to Feature Image)

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2221889
    Maggie

    Hi Team,

    How to create Feature Similar to Feature Image using element, this feature is for embeded maps code what to put are the code of wpgmaps.com

    Example of code: [wpgmza id=”140″]
    Link: https://headquartersoffice.com/wsp/

    Please educate me on this. Thank you.

    #2222017
    David
    Staff
    Customer Support

    Hi there,

    you could use a WordPress Custom Field to store your ‘code’:

    1. Edit a post where you want this applied, and in the Options ( 3 dot menu ) -> Preferences –> Panels enable the Custom Fields.

    2. Now at the foot of the editor you can Create a New Custom Field.
    Give you field a Name eg. wpgmap
    And add the code to the Value field: [wpgmza id="140"]

    3. Now each time you create a post where you want to add this custom field you will be able to select wpgmap from the list and give it a value.

    4. With the value stored we can now output that shortcode using a PHP Snippet:

    add_action('generate_after_entry_header', function(){
        $wpgmap = get_post_meta( get_the_id(), 'wpgmap', true );
        if ( $wpgmap && is_single() ) {
            echo do_shortcode( $wpgmap );
        }
    });

    This will display it on the single post after the Entry header.

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    #2300671
    Maggie

    Hi, what should i choose to Create a New Custom Field? Thanks.

    #2301101
    Ying
    Staff
    Customer Support

    There’s a link that says “enter new” below the dropdown list:
    https://www.screencast.com/t/L0qMiRZzpW

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