-
▼
2012
(336)
-
▼
September
(25)
- How to Use External Domain Names With WordPress
- How to Make a DIV Link in WordPress
- How to Embed Links Within a Picture in WordPress
- How to Install Thematic WordPress Themes
- How to Install WordPress on a Pair.com Account
- How to Add Your Blogspot Friends on WordPress
- How to Change Your WordPress Template
- How to Upload a WordPress Blog on to My HostGator ...
- How to Embed a Podcast in WordPress
- How to Transfer WordPress to New Domain Using File...
- How to Change the Color on a WordPress Template
- How to Upload Videos to Wordpress
- How to Upload HTML Files to WordPress
- How to Set Up WordPress AWS C2
- How to Connect FeedBurner to WordPress
- How to Publish Scheduled WordPress Posts
- How to Make a WordPress Ping
- How to Install File Share in WordPress on CentOS
- How to Post Web Clips to a Wordpress Blog Directly...
- How to Email a Blog Entry to WordPress
- How to Put Your WordPress Page in FileZilla
- How to Add a Short Code to WordPress
- How to Activate WordPress in GoDaddy
- How to Create a Home Page with WordPress
- How to Rename a WordPress Theme in the Dashboard
-
▼
September
(25)
adsense
How to Add a Short Code to WordPress
1. Open your 'functions.php' file in a code editor and scroll down to the bottom. Write a function that returns whatever output you want to appear whenever you use the finished short code. Here is an example:function some_stuff() {return 'Whatever you want to output.';}
2. Add this built-in WordPress 'hook' function below the short code function:add_shortcode('myshortcode', 'some_stuff');Replace 'myshortcode' with whatever you want to name your short code. This is the name you will use when typing the short code in a post. Replace 'some_stuff' with the name of the function that handles the short code's output.
3. Change your code like this if you want to add an attribute to your short code:function some_stuff() {Extract(shortcode_atts(array('thing' => ''), $atts));Return '
'.$content.'
';}Replace 'thing' with the name you want to give your attribute, such as 'href' for a short code that creates links or 'columns' for a short code that creates columns. Return a string containing the tag code and concatenate -- break the string to add in more PHP code -- the attribute as a variable into the string. Also concatenate the variable 'content' between the tags.
4. Upload your edited 'functions.php' file and save it over the earlier version. Log into the WordPress dashboard and edit a post. Click the 'Visual' editor tab and then write out your short code in the post like this:[myshortcode thing='some-value']Content goes in here.[/myshortcode]
7:46 AM | Filed Under | 0 Comments
Comments
Popular Posts
-
1. Log in to your Weebly account. 2. Click 'Theme Editor.' 3. Click on the 'Design' tab. 4. Select 'Edit CSS/HTM...
-
1. Sign up for a publisher account at Bidvertiser. Submit basic contact information and confirm your email address to get started. 2. Lo...
-
1. Log in to your WordPress dashboard. 2. Open the 'Appearance' section on the left side of the WordPress dashboard and then cli...
-
1. Open your WordPress Dashboard in your preferred browser. It is accessed at the '/wp-admin' location of your site. For example, ...
-
Facebook Widget 1. Create a Facebook fan page for your blog, if you don't already have one. You will have to manually share content wi...
-
1. Download and install the WordPress for BlackBerry app via BlackBerry App World. Download the version that corresponds with your BlackBe...
-
1. Go to your WordPress blog's administrative control panel. 2. Click the 'Settings' button on the left-side navigation menu...
-
1. Click the 'Add Contact' button on the 'Add New Post' page. This opens the 'Add a Contact Form' page. 2. Click...
-
1. Register an account with Amazon Web Services Cloud. If you have an existing Amazon account, enter your email address in the appropriate...
-
1. Log into your WordPress.com account using your user name and password. 2. Hover your cursor over the 'My Blogs' tab at the to...
Post a Comment