• Resolved NoWe

    (@nowe)


    I have added some extra Meta Data fields like email and url
    this all works fine using wpsl_meta_box_fields
    ’email’ => array(
    ‘label’ => __( ‘Email’, ‘wpsl’ )
    )

    I was wondering if it is possible to turn these extra meta fields into shortcodes
    This would make it possible to place them anywhere on the page

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi there, thanks for writing.

    I’m afraid that is not possible out of the box. However, it could be possible to build your own shortcodes in your functions.php file to retrieve those metadata fields from the WordPress database, but that is outside the scope of our support and it is something you should try and do yourself, sorry about that.

    Best regards,

    Thread Starter NoWe

    (@nowe)

    function display_wpsl_phone_number() {

        global $post;

        $phone = get_post_meta( $post->ID, ‘wpsl_phone’, true );

        if ( $phone ) {

            return ‘<i class=”fas fa-id-badge”></i> <a href=”tel:’ . esc_attr( $phone ) . ‘”>’ . esc_html( $phone ) . ‘</a>’;

        }

        return ”;

    }

    // Register shortcode

    add_shortcode(‘wpsl_phone_number’, ‘display_wpsl_phone_number’);

    which gives the following shortcode
    [wpsl_phone_number]

    • This reply was modified 10 months, 2 weeks ago by NoWe. Reason: solution
    • This reply was modified 10 months, 2 weeks ago by NoWe. Reason: red
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Extra Meta Data Fields shortcode’ is closed to new replies.