[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 2 posts - 1 through 2 (of 2 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/

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