• Hi,

    I have a very strange effect in my custom shortcode.
    I want to build an accordion on different content pages via shortcode. But I can’t execute the js multiple times, just one time on initial load.

    I can’t create the accordion via css, because my input fields are NOT in the DOM. So it can’t be an css problem.

    This is how I add the shortcode-accordion

    function add_accordion($atts){
        $a = shortcode_atts( array(
              'id' => '',
              'class' => ''
           ), $atts );
    
            ob_start();
    
            wp_enqueue_script( "accordionjs" );
    
            set_query_var( 'post_id', absint( $a['id']) );
            set_query_var( 'class',  $a['class'] );
    
           get_template_part('template-parts/accordion');
    
            return ob_get_clean();
    }
    
    add_shortcode( 'accordion', 'add_accordion' );

    In my accordion.php I am not able to render a simple checkbox like this:
    <input type="checkbox" name="chk1" id="chk1" />

    Where are my input field or the script tags for javascript?
    I am using AngularJS with the current WordPress-Version.

    Do you know this problem?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Shortcode doesnt render checkbox’ is closed to new replies.