Register a shortcode for a scrollbox

<?php
    // function that runs when shortcode is called
    function dk_c3scrollbox_shortcode() { 
     
    // Things that you want to do. 
    $message = 'Hello world!'; 
     
    // Output needs to be return
    return $message;
    } 
    // register shortcode
    add_shortcode('c3scrollbox', 'wpb_demo_shortcode');



<?php
    //Register Shortcodes
    add_action( 'init', 'register_shortcodes');
 
    function register_shortcodes(){
        add_shortcode('c3scrollbox', 'c3scrollbox_function');
    }
 
    //Display Shortcodes
    function c3scrollbox_function($atts, $content = null){
 
        extract(shortcode_atts(
            array(
                "id" => ''
        ), $atts));
 
 
        $return_string = '<div style="overflow-y: auto; height:250px;border:1px solid #ddd;padding:6px; ">';
        $return_string .= $content.'</div>';
 
        wp_reset_query();
 
        return $return_string;
    }
?> 

Posted

in

by

Tags: