Search
 
SCRIPT & CODE EXAMPLE
 

PHP

wordpress add shortcode with parameters

/**
 * /**
 * The [wporg] shortcode.
 *
 * Accepts a title and will display a box.
 *
 * @param array  $atts    Shortcode attributes. Default empty.
 * @param string $content Shortcode content. Default null.
 * @param string $tag     Shortcode tag (name). Default empty.
 * @return string Shortcode output.
 */
function wporg_shortcode( $atts = [], $content = null, $tag = '' ) {
    // normalize attribute keys, lowercase
    $atts = array_change_key_case( (array) $atts, CASE_LOWER );
 
    // override default attributes with user attributes
    $wporg_atts = shortcode_atts(
        array(
            'title' => 'WordPress.org',
        ), $atts, $tag
    );
 
    // start box
    $o = '<div class="wporg-box">';
 
    // title
    $o .= '<h2>' . esc_html__( $wporg_atts['title'], 'wporg' ) . '</h2>';
 
    // enclosing tags
    if ( ! is_null( $content ) ) {
        // $content here holds everything in between the opening and the closing tags of your shortcode. eg.g [my-shortcode]content[/my-shortcode].
        // Depending on what your shortcode supports, you will parse and append the content to your output in different ways.
        // In this example, we just secure output by executing the_content filter hook on $content.
        $o .= apply_filters( 'the_content', $content );
    }
 
    // end box
    $o .= '</div>';
 
    // return output
    return $o;
}
 
/**
 * Central location to create all shortcodes.
 */
function wporg_shortcodes_init() {
    add_shortcode( 'wporg', 'wporg_shortcode' );
}
 
add_action( 'init', 'wporg_shortcodes_init' );
Comment

wordpress add shortcode with parameters

/**
 * /**
 * The [wporg] shortcode.
 *
 * Accepts a title and will display a box.
 *
 * @param array  $atts    Shortcode attributes. Default empty.
 * @param string $content Shortcode content. Default null.
 * @param string $tag     Shortcode tag (name). Default empty.
 * @return string Shortcode output.
 */
function wporg_shortcode( $atts = [], $content = null, $tag = '' ) {
    // normalize attribute keys, lowercase
    $atts = array_change_key_case( (array) $atts, CASE_LOWER );
 
    // override default attributes with user attributes
    $wporg_atts = shortcode_atts(
        array(
            'title' => 'WordPress.org',
        ), $atts, $tag
    );
 
    // start box
    $o = '<div class="wporg-box">';
 
    // title
    $o .= '<h2>' . esc_html__( $wporg_atts['title'], 'wporg' ) . '</h2>';
 
    // enclosing tags
    if ( ! is_null( $content ) ) {
        // $content here holds everything in between the opening and the closing tags of your shortcode. eg.g [my-shortcode]content[/my-shortcode].
        // Depending on what your shortcode supports, you will parse and append the content to your output in different ways.
        // In this example, we just secure output by executing the_content filter hook on $content.
        $o .= apply_filters( 'the_content', $content );
    }
 
    // end box
    $o .= '</div>';
 
    // return output
    return $o;
}
 
/**
 * Central location to create all shortcodes.
 */
function wporg_shortcodes_init() {
    add_shortcode( 'wporg', 'wporg_shortcode' );
}
 
add_action( 'init', 'wporg_shortcodes_init' );
Comment

wordpress add shortcode with parameters

/**
 * /**
 * The [wporg] shortcode.
 *
 * Accepts a title and will display a box.
 *
 * @param array  $atts    Shortcode attributes. Default empty.
 * @param string $content Shortcode content. Default null.
 * @param string $tag     Shortcode tag (name). Default empty.
 * @return string Shortcode output.
 */
function wporg_shortcode( $atts = [], $content = null, $tag = '' ) {
    // normalize attribute keys, lowercase
    $atts = array_change_key_case( (array) $atts, CASE_LOWER );
 
    // override default attributes with user attributes
    $wporg_atts = shortcode_atts(
        array(
            'title' => 'WordPress.org',
        ), $atts, $tag
    );
 
    // start box
    $o = '<div class="wporg-box">';
 
    // title
    $o .= '<h2>' . esc_html__( $wporg_atts['title'], 'wporg' ) . '</h2>';
 
    // enclosing tags
    if ( ! is_null( $content ) ) {
        // $content here holds everything in between the opening and the closing tags of your shortcode. eg.g [my-shortcode]content[/my-shortcode].
        // Depending on what your shortcode supports, you will parse and append the content to your output in different ways.
        // In this example, we just secure output by executing the_content filter hook on $content.
        $o .= apply_filters( 'the_content', $content );
    }
 
    // end box
    $o .= '</div>';
 
    // return output
    return $o;
}
 
/**
 * Central location to create all shortcodes.
 */
function wporg_shortcodes_init() {
    add_shortcode( 'wporg', 'wporg_shortcode' );
}
 
add_action( 'init', 'wporg_shortcodes_init' );
Comment

wordpress add shortcode with parameters

/**
 * /**
 * The [wporg] shortcode.
 *
 * Accepts a title and will display a box.
 *
 * @param array  $atts    Shortcode attributes. Default empty.
 * @param string $content Shortcode content. Default null.
 * @param string $tag     Shortcode tag (name). Default empty.
 * @return string Shortcode output.
 */
function wporg_shortcode( $atts = [], $content = null, $tag = '' ) {
    // normalize attribute keys, lowercase
    $atts = array_change_key_case( (array) $atts, CASE_LOWER );
 
    // override default attributes with user attributes
    $wporg_atts = shortcode_atts(
        array(
            'title' => 'WordPress.org',
        ), $atts, $tag
    );
 
    // start box
    $o = '<div class="wporg-box">';
 
    // title
    $o .= '<h2>' . esc_html__( $wporg_atts['title'], 'wporg' ) . '</h2>';
 
    // enclosing tags
    if ( ! is_null( $content ) ) {
        // $content here holds everything in between the opening and the closing tags of your shortcode. eg.g [my-shortcode]content[/my-shortcode].
        // Depending on what your shortcode supports, you will parse and append the content to your output in different ways.
        // In this example, we just secure output by executing the_content filter hook on $content.
        $o .= apply_filters( 'the_content', $content );
    }
 
    // end box
    $o .= '</div>';
 
    // return output
    return $o;
}
 
/**
 * Central location to create all shortcodes.
 */
function wporg_shortcodes_init() {
    add_shortcode( 'wporg', 'wporg_shortcode' );
}
 
add_action( 'init', 'wporg_shortcodes_init' );
Comment

wordpress add shortcode with parameters

/**
 * /**
 * The [wporg] shortcode.
 *
 * Accepts a title and will display a box.
 *
 * @param array  $atts    Shortcode attributes. Default empty.
 * @param string $content Shortcode content. Default null.
 * @param string $tag     Shortcode tag (name). Default empty.
 * @return string Shortcode output.
 */
function wporg_shortcode( $atts = [], $content = null, $tag = '' ) {
    // normalize attribute keys, lowercase
    $atts = array_change_key_case( (array) $atts, CASE_LOWER );
 
    // override default attributes with user attributes
    $wporg_atts = shortcode_atts(
        array(
            'title' => 'WordPress.org',
        ), $atts, $tag
    );
 
    // start box
    $o = '<div class="wporg-box">';
 
    // title
    $o .= '<h2>' . esc_html__( $wporg_atts['title'], 'wporg' ) . '</h2>';
 
    // enclosing tags
    if ( ! is_null( $content ) ) {
        // $content here holds everything in between the opening and the closing tags of your shortcode. eg.g [my-shortcode]content[/my-shortcode].
        // Depending on what your shortcode supports, you will parse and append the content to your output in different ways.
        // In this example, we just secure output by executing the_content filter hook on $content.
        $o .= apply_filters( 'the_content', $content );
    }
 
    // end box
    $o .= '</div>';
 
    // return output
    return $o;
}
 
/**
 * Central location to create all shortcodes.
 */
function wporg_shortcodes_init() {
    add_shortcode( 'wporg', 'wporg_shortcode' );
}
 
add_action( 'init', 'wporg_shortcodes_init' );
Comment

wordpress add shortcode with parameters

/**
 * /**
 * The [wporg] shortcode.
 *
 * Accepts a title and will display a box.
 *
 * @param array  $atts    Shortcode attributes. Default empty.
 * @param string $content Shortcode content. Default null.
 * @param string $tag     Shortcode tag (name). Default empty.
 * @return string Shortcode output.
 */
function wporg_shortcode( $atts = [], $content = null, $tag = '' ) {
    // normalize attribute keys, lowercase
    $atts = array_change_key_case( (array) $atts, CASE_LOWER );
 
    // override default attributes with user attributes
    $wporg_atts = shortcode_atts(
        array(
            'title' => 'WordPress.org',
        ), $atts, $tag
    );
 
    // start box
    $o = '<div class="wporg-box">';
 
    // title
    $o .= '<h2>' . esc_html__( $wporg_atts['title'], 'wporg' ) . '</h2>';
 
    // enclosing tags
    if ( ! is_null( $content ) ) {
        // $content here holds everything in between the opening and the closing tags of your shortcode. eg.g [my-shortcode]content[/my-shortcode].
        // Depending on what your shortcode supports, you will parse and append the content to your output in different ways.
        // In this example, we just secure output by executing the_content filter hook on $content.
        $o .= apply_filters( 'the_content', $content );
    }
 
    // end box
    $o .= '</div>';
 
    // return output
    return $o;
}
 
/**
 * Central location to create all shortcodes.
 */
function wporg_shortcodes_init() {
    add_shortcode( 'wporg', 'wporg_shortcode' );
}
 
add_action( 'init', 'wporg_shortcodes_init' );
Comment

wordpress add shortcode with parameters

/**
 * /**
 * The [wporg] shortcode.
 *
 * Accepts a title and will display a box.
 *
 * @param array  $atts    Shortcode attributes. Default empty.
 * @param string $content Shortcode content. Default null.
 * @param string $tag     Shortcode tag (name). Default empty.
 * @return string Shortcode output.
 */
function wporg_shortcode( $atts = [], $content = null, $tag = '' ) {
    // normalize attribute keys, lowercase
    $atts = array_change_key_case( (array) $atts, CASE_LOWER );
 
    // override default attributes with user attributes
    $wporg_atts = shortcode_atts(
        array(
            'title' => 'WordPress.org',
        ), $atts, $tag
    );
 
    // start box
    $o = '<div class="wporg-box">';
 
    // title
    $o .= '<h2>' . esc_html__( $wporg_atts['title'], 'wporg' ) . '</h2>';
 
    // enclosing tags
    if ( ! is_null( $content ) ) {
        // $content here holds everything in between the opening and the closing tags of your shortcode. eg.g [my-shortcode]content[/my-shortcode].
        // Depending on what your shortcode supports, you will parse and append the content to your output in different ways.
        // In this example, we just secure output by executing the_content filter hook on $content.
        $o .= apply_filters( 'the_content', $content );
    }
 
    // end box
    $o .= '</div>';
 
    // return output
    return $o;
}
 
/**
 * Central location to create all shortcodes.
 */
function wporg_shortcodes_init() {
    add_shortcode( 'wporg', 'wporg_shortcode' );
}
 
add_action( 'init', 'wporg_shortcodes_init' );
Comment

PREVIOUS NEXT
Code Example
Php :: laravel blade if else condition 
Php :: get all error message in array form laravel validation in laravel 
Php :: validate names regex php 
Php :: preg_split in php 
Php :: acf add options page to custom post type 
Php :: SQLSTATE[42S02] lumen 
Php :: laravel debugbar false 
Php :: how to add multiple images in php 
Php :: laravel notification 
Php :: php get multiple url parameters 
Php :: number data type in laravel migration 
Php :: composer install phpWord 
Php :: count cpt wp 
Php :: laravel where() method 
Php :: flatten in array php 
Php :: laravel casts AsCollection 
Php :: php method type hinting 
Php :: laravel valet subdomain 
Php :: disadvantages of php 
Php :: array_map in php 
Php :: laravel filter array 
Php :: drupal 8 entity_view 
Php :: php mysqli insert name adress 
Php :: laravel migration tinyint length 
Php :: this app is not allowed to query for scheme fb-messenger" 
Php :: woocommerce unset custom checkout field 
Php :: pregmatch php only numbers and comma and dot 
Php :: hummingbird remove caching specific page php 
Php :: unnamed place placeholders pdo 
Php :: php move in array 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =