• Hi,
    I am working on a custom theme, i want to add colorpicker in shortcode attributes so by which i can select background color OR text color for shortcode contents.

    I tried to search alot for solution but not able to find any.

    Any help will be appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi Ajay! hope you are doing well today.

    Look up this little function:

    function ajay_shortcode( $atts ) {
    
    	$a = shortcode_atts( array(
    	        'background' => ''
    	    ), $atts );
    	$bg = ( "{$a['background']}" != "" ) ? "{$a['background']}" : "#000" ;
    
    	ob_start();
    	?>
    		<div style="background:<?php echo $bg; ?>;">
    			this is a division
    		</div>
    	<?php
    	return ob_get_clean();
    
    }
    
    add_shortcode("ajay", "ajay_shortcode");
    
    // test-use [ajay background="red"]
    echo do_shortcode('[ajay background="red"]');
    Thread Starter Ajay Tiwari

    (@mmajay)

    Hey Samual, thanks for your response.. my issue is i have added shortcode button in tinymce & on click it gives option to add attribute contents to user in that area for color option i want to show color picker..

    Another thing i sent an email about weeks before but i have not received your response yet..

    Ajay

    Hey Ajay!

    Can you use pastebin.com to paste us the code you use for both adding tool to TinyMCE and shortcode function? thanks!

    Oh, I thought you didn’t see my reply, well, I replied to your email the day after you have sent it. If you don’t find that email, let me know so I’ll forward it to you again 😉

    Thread Starter Ajay Tiwari

    (@mmajay)

    Just found your email sending you reply with access to my code.

    Thanks
    Ajay

    Hi Ajay,

    Just letting you know that yet I haven’t received anything on my email.

    🙂

    Thread Starter Ajay Tiwari

    (@mmajay)

    Hi Samuel,

    Just sent email please check again.

    Ajay

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Color Picker in shortcode attributes’ is closed to new replies.