Custom shortcode with attributes

Posted on 16th September, 2017 118 Comments

Building a custom shortcode is pretty easy.
Declare the vars and use ob_get_clean() to output the function.

<?php
function my_shortcode_func( $atts ) {
    extract( shortcode_atts( array(
    	'title' => '',
    	'desc' => '',
        'pdf' => '',
    ), $atts ) );

    ob_start();
?>



<p><?php echo $desc; ?></p>
<a class="button white" href="<?php echo $pdf; ?>" target="new"><?php echo $title; ?></a>


<?php
	$my_shortcode = ob_get_clean();
    return $my_shortcode;   
} 
add_shortcode( 'my_shortcode', 'my_shortcode_func' );

The shortcode should include the title, desc and url for the link.
[add_pdf_shortcode title=“the title” desc=“the description” pdf=“http://link.com”]

Comments

To preserve code added to a comment you can wrap your code in short tags
by using [square brackets]:

  1. PHP use - [php] <?php code here ?> [/php]
  2. CSS use - [css] #code-here {} [/css]
  3. HTML use - [html] <div> code here </div> [/html]
  4. JS use - [js] $(".codeHere") [/js]

JamesVen

21st, Oct, 20

clouds than many of the others in her anyway scabies. [url=https://ciamedusa.com/#]generic cialis cheap[/url] Crfvcn ezhjyr

Cissr

12th, Nov, 20

USA
european pharmacy cialis [url=https://cciialiss.com/]buy cialis usa[/url] cialis miami

Cissr

12th, Nov, 20

Brand
cialis 10mg cost [url=https://cciialiss.com/]best generic cialis[/url] buy cialis bangkok

Cissr

12th, Nov, 20

Brand
does generic cialis really work [url=https://cciialiss.com/]buy cialis canada[/url] cialis in your 30s

Cissr

13th, Nov, 20

USA
cialis pill look like [url=https://cciialiss.com/]au cialis[/url] cialis for women dose

Cissr

13th, Nov, 20

Brand
generic cialis online usa [url=https://cciialiss.com/]cialis without prescriptions[/url] cialis 40 mg doses

Cissr

13th, Nov, 20

USA
cialis daily online [url=https://cciialiss.com/]best generic cialis[/url] experiences with cialis

Cciialiss

13th, Nov, 20

Generic
cialis needed [url=https://cciialiss.com/]au cialis[/url] einnahme 40 mg cialis

Cciialiss

13th, Nov, 20

USA
cialis use by dates [url=https://cciialiss.com/]buy cialis online[/url] generic equivalent for cialis

Cciialiss

13th, Nov, 20

Brand
reasons for cialis [url=https://cciialiss.com/]cialis generic online pharmacy[/url] what is cialis dose

Cciialiss

14th, Nov, 20

Brand
generic cialis tadalafil 20mg [url=https://cciialiss.com/]buy cialis online[/url] cialis soft tabs online

Cciialiss

14th, Nov, 20

Generic
cialis cheapest uk [url=https://cciialiss.com/#]www cciialiss[/url] cheapest cialis in india

Cciialiss

14th, Nov, 20

Generic
cialis chemical name [url=https://cciialiss.com/]tadalafil cialis[/url] cialis coupon discounts

Cciialiss

14th, Nov, 20

Brand
most effective use cialis [url=https://cciialiss.com/]best generic cialis[/url] using cialis recreational

Cciialiss

14th, Nov, 20

USA
getting most out cialis [url=https://cciialiss.com/#]www cciialiss[/url] buy cialis online consultation

Cciialiss

14th, Nov, 20

USA
breaking cialis in half [url=https://cciialiss.com/]buy cialis brand[/url] cialis is it effective

Cciialiss

14th, Nov, 20

USA
maximum mg cialis [url=https://cciialiss.com/#]cciialiss com[/url] purchasing cialis online

Cciialiss

14th, Nov, 20

Brand
cialis cure ed [url=https://cciialiss.com/]generic cialis[/url] cialis professional

Cciialiss

15th, Nov, 20

USA
what cialis dose [url=https://cciialiss.com/]generic cialis[/url] order cialis professional

Cciialiss

15th, Nov, 20

Brand
cialis pharmacy [url=https://cciialiss.com/]buy cialis[/url] tadalafil without prescription

Cciialiss

15th, Nov, 20

Brand
generic cialis made india [url=https://cciialiss.com/]au cialis[/url] cialis eye effects

Cciialiss

15th, Nov, 20

USA
cialis prices india [url=https://cciialiss.com/]cciialisscom[/url] cialis england

Cciialiss

15th, Nov, 20

USA
cialis 5mg daily price [url=https://cciialiss.com/]tadalafil cialis[/url] benefits using cialis

Cciialiss

15th, Nov, 20

Brand
cialis daily use long [url=https://cciialiss.com/]buy cialis in australia[/url] purchase 5mg cialis

Cciialiss

15th, Nov, 20

Brand
cialis online without rx [url=https://cciialiss.com/]generic cialis[/url] buying cialis europe

Cciialiss

15th, Nov, 20

Brand
orange blue cialis [url=https://cciialiss.com/]cialis generic online pharmacy[/url] results of cialis

Cciialiss

15th, Nov, 20

Brand
cialis pain in legs [url=https://cciialiss.com/]cialis pills[/url] buy cialis bangkok

Cciialiss

16th, Nov, 20

Brand
cialis one day cost [url=https://cciialiss.com/]cialis 20mg[/url] cialis how many hours

Cciialiss

16th, Nov, 20

Generic
current cost cialis [url=https://cciialiss.com/]tadalafil cialis[/url] cialis daily costs

Cciialiss

16th, Nov, 20

Brand
faq cialis [url=https://cciialiss.com/]buy cialis usa[/url] cialis healthy men

Cciialiss

16th, Nov, 20

Brand
buy cialis drugstore [url=https://cciialiss.com/]cialis 20mg pills[/url] cialis death

ccialisny

17th, Nov, 20

despre medicamentul cialis [url=https://ccialisny.com/]order cialis without prescription[/url] cialis indian brands

ccialisny

18th, Nov, 20

drinking while on cialis [url=https://ccialisny.com/]cialis mail order[/url] cialis from eu

ccialisny

18th, Nov, 20

buy cialis online us [url=https://ccialisny.com/]order cialis with dapoxtine[/url] female use of cialis

ccialisny

18th, Nov, 20

cialis en internet [url=https://ccialisny.com/]order cialis overnight delivery[/url] cialis class of drugs

llevitraaa

19th, Nov, 20

levitra orosolubile mezza pastiglia [url=https://llevitraa.com/]costco pharmacy prices levitra[/url] costo in farmacia del levitra

llevitraaa

19th, Nov, 20

levitra professional wikipedia [url=https://llevitraa.com/]levitra wholesale no prescription[/url] is levitra or viagra better

llevitraaa

19th, Nov, 20

acheter levitra 10 mg [url=https://llevitraa.com/]levitra buy online cheap[/url] es peligroso el levitra

llevitraaa

20th, Nov, 20

walmart pharmacy price levitra [url=https://llevitraa.com/]cheap levitra for sale[/url] levitra orosolubile e ansia da prestazione

llevitraaa

20th, Nov, 20

levitra 10 mg pret [url=https://llevitraa.com/]levitra sales in usa[/url] levitra e ansia

llevitraaa

20th, Nov, 20

il migliore tra cialis viagra e levitra [url=https://llevitraa.com/]levitra buy 20mg[/url] ou acheter du levitra generique

llevitraaa

20th, Nov, 20

levitra compresse da 20 mg [url=https://llevitraa.com/]generic levitra buy online uk[/url] reacciones secundarias de levitra

llevitraaa

20th, Nov, 20

levitra kimler kullanabilir [url=https://llevitraa.com/]generic levitra buy india[/url] levitra onset duration

llevitraaa

21st, Nov, 20

was ist besser levitra oder cialis [url=https://llevitraa.com/]levitra buy online cheap[/url] levitra libera vendita

llevitraaa

21st, Nov, 20

cvs pharmacy prices levitra [url=https://llevitraa.com/]levitra buy online is it safe[/url] efectos de levitra en el hombres

fixcialel

25th, Nov, 20

buy over counter cialis [url=https://cialisfix.com/]cialis generic buy[/url] buy generic cialis online

RobertTaulp

25th, Nov, 20

bookmarked!!, I love your blog!

viagra for women buy [url=https://hiviagrarx.com/]viagra 7 eleven [/url] viagra to help premature ejaculation

fixcialel

25th, Nov, 20

cialis everyday dose [url=https://cialisfix.com/]ordering cialis in canada[/url] tadalafil package insert

fixcialel

26th, Nov, 20

cialis 5mg daily [url=https://cialisfix.com/]order original cialis[/url] cialis libido

fixcialel

26th, Nov, 20

health online cialis [url=https://cialisfix.com/]how to order cialis[/url] cialis without prescription in canada

펀초

28th, Nov, 20

The following time I read a blog, I wish that it does not dissatisfy me as long as this. I imply, I recognize it was my choice to review, yet I actually assumed youd have something fascinatin펀초

g to claim. All I hear is a lot of whimpering regarding something that you could fix if you werent also hectic seeking attention.

ciialel

28th, Nov, 20

best pharmacy cialis [url=https://cciialiis.com/]order cialis black online[/url] order real cialis online

ciialel

28th, Nov, 20

cialis vision loss [url=https://cciialiis.com/]ordering cialis online illegal[/url] cialis retail pricing

ciialel

28th, Nov, 20

effects cialis exercise [url=https://cciialiis.com/]cialis order[/url] cialis in females

ciialel

29th, Nov, 20

buy cialis vancouver [url=https://cciialiis.com/]mail order cialis[/url] impotence drugs cialis

ciialel

29th, Nov, 20

long use cialis [url=https://cciialiis.com/]usa cialis online[/url] many mg daily cialis

Cciialiss

30th, Nov, 20

USA
price cialis 36 hour [url=https://cciialiss.com/]order generic cialis online[/url] muscle pain from cialis

Cciialiss

30th, Nov, 20

Brand
tadalafil maximum dose [url=https://cciialiss.com/]order generic cialis[/url] cialis is it effective

Cciialiss

30th, Nov, 20

Generic
buy cialis without prescription uk [url=https://cciialiss.com/]order generic cialis[/url] cialis prices in us

Cciialiss

30th, Nov, 20

Generic
cheap cialis one day [url=https://cciialiss.com/]order cialis canada[/url] generic cialis vs brand cialis

Cciialiss

30th, Nov, 20

Generic
cialis vs levitra [url=https://cciialiss.com/]cialis order online[/url] choose cialis

Cciialiss

30th, Nov, 20

USA
cialis instead of flomax [url=https://cciialiss.com/]order cialis[/url] generic cialis mexico

Cciialiss

01st, Dec, 20

Generic
cialis every day review [url=https://cciialiss.com/]cialis mail order usa[/url] buy cialis in india

Leave a Comment

To preserve code added to a comment you can wrap your code in short tags
by using [square brackets]:

  1. PHP use - [php] <?php code here ?> [/php]
  2. CSS use - [css] #code-here {} [/css]
  3. HTML use - [html] <div> code here </div> [/html]
  4. JS use - [js] $(".codeHere") [/js]