To create a short-code for a search box (WordPress websites):
1. In your WordPress dashboard go to ‘Appearance Editor’.
2. Scroll through the ‘Templates’ list on the right-hand side until you find ‘Theme Functions’ and click here.
3. On the left-hand side, you’lll see the content of the ‘Theme Functions’ (‘functions.php’) file.
4. Copy the entire code and paste it in a separate ‘.txt’ or ‘.doc’ file, so that you have a back-up of the original file.
5. Now return to the functions.php’ file and copy the code below:
/* Add short-code for B.com searchbox widget [bcom_searchbox] */
function bcom_searchbox( $atts ){
$b_sb_ins = ' XXX ';
$b_sb_script = 'script type="text/javascript"// ![CDATA[
(function(d, sc, u) {
var s = d.createElement(sc), p = d.getElementsByTagName(sc)[0];
s.type = \'text/javascript\';
s.async = true;
s.src = u + \'?v=\' + (+new Date());
p.parentNode.insertBefore(s,p);
})(document, \'script\', \'//aff.bstatic.com/static/affiliate_base/js/flexiproduct.js\');
// ]]/script';
return $b_sb_ins . $b_sb_script ;
add_shortcode( 'bcom_searchbox', 'bcom_searchbox' );
6. Now paste it at the very end of the ‘functions.php’ code.
7. Go back to the Partner Centre, copy the piece of search box code before ‘ins’.
8. Return to the ‘functions.php’ file and replace ‘XXX’ with the code you just copied.
9. Click ‘Update File’ to save the changes.
And you’re done!
Now you can use the [bcom_searchbox] short-code anywhere you like on your site.
Comments
0 comments
Article is closed for comments.