• Can someone tell if there are ready made code for shortcodes to add a background to my content

    For example, maybe I want my content to have a box around it and have a subtle shadow around the box

    I think I know enough to be able to code myself – but I thought this is such a simple thing, that someone is bound to have already coded?

    Thanks

    Omar

Viewing 2 replies - 1 through 2 (of 2 total)
  • Maybe, but things like this that do exist are hard to find sometimes unless someone can point you in the right direction.

    However you might want to sort the code yourself. The code below will get you started, just add it to your themes functions.php file or into a Plugin.

    If you are adding it to your theme it is best to do it via a child theme, but you can test it works in your main theme first:

    // Usage: [custom-box]Content inside your custom box![/custom-box]
    function custom_box_shortcode($atts, $content=null ){
    	return "<div style=\"border: 1px solid #ccc;\">{$content}</div>";
    }
    add_shortcode('custom-box', 'custom_box_shortcode');

    Thank you this helps but the background remains on all the pages after that i want to make button like Try This and when user clicks on it the background changes one more click defeault ! that can be done ? thank you very much…

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shortcode for adding background to content’ is closed to new replies.