Custom Download Button on WordPress

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2742 Reply

    Ron
    Keymaster

    Custom Download Button
    Add on functions.php (preferably on a child theme)

    function dlbutton( $atts, $content = null ) {
        extract(shortcode_atts(array(
    	"id" 	=> '',
            "href"  => '',
    	"title" => '',
            "style" => '',
    	"text"	=> ''  
        ), $atts));
        return '<a class="dlbutton" id="'.$id.'" href="'.$href.'" title="'.$title.'" style="'.$style.'">' . $text . '</a>';
    }
    add_shortcode('dlbutton', 'dlbutton');

    CSS Style

    .dlbutton {
        display: table;
        background-color: #FFDA25;
        border: 1px solid #444;
        border-radius: 3px;
        box-shadow: 0 0 2px #000;
        margin: 8px;
        padding: 6px 8px;
        line-height: 1;
        font-family: tahoma, sans-serif;
    }
    .dlbutton:hover {
        background-color: #F8FF03;
        box-shadow: 1px 1px 2px #000;
    }

    How to Use on Posts

    [dlbutton href="url or location of file" title="Title on Hover" text="Button Name"]
    
    #2743

    Ron
    Keymaster

    Important Text Block

    On functions.php

    function short_important( $atts, $content=null, $code="" ) {
        extract(shortcode_atts(array(
            "style" => '',
            "title" => ''    
        ), $atts));
        return '<div class="short-important" title="'.$title.'" style="'.$style.'">' . $content . '</div>';
    }
    add_shortcode('important', 'short_important');

    CSS Style

    .short-important {
       background-image: url("bg-honeycomb.png");
       background-color: #FBC22A; 
       border: 1px solid #888; 
       padding: 8px;
    }

    Usage

    [important]Sample Text[/important]
    
Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Custom Download Button on WordPress
Your information: