-
AuthorPosts
-
December 17, 2014 at 8:45 pm #166778
And have it in the short code list along with the others?
something like this…
<span style=”color: #ff0000; line-height: 10px; vertical-align: middle; letter-spacing: -1px;”>Can this be a custom short code?</span>
thanks
December 18, 2014 at 7:43 am #167011Hi there,
Thanks for writing in!
Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.
After that you can add following code in your child theme’s functions.php file:
// Custom Shortcode // ============================================================================= function custom_shortcode() { $output = '<span style="color: #ff0000; line-height: 10px; vertical-align: middle; letter-spacing: -1px;">Can this be a custom short code?</span>'; return $output; } add_filter('init', 'add_custom_shortcode'); function add_custom_shortcode() { add_shortcode('custom_shortcode_name', 'custom_shortcode'); }
Now you can replace custom_shortcode_name with your custom shortcode’s name and you can insert it in your website like this:
[custom_shortcode_name]
Adding it to the shortcodes option, requires more in depth customization, that regretfully will fall beyond the scope of support we can offer. You may wish to consult a developer to assist you with this. X is quite extensible with child themes, so there are plenty of possibilities.
Thanks!
December 19, 2014 at 11:26 pm #168011That works great thanks and I have aText app so I only need to put a shortcut for the shortcode shortcut.
Now how do I put multiple shortcuts in the child themes functions.php file?
December 21, 2014 at 6:32 pm #168449Hey there,
For more details on creating shortcodes, please see the links below.
http://codex.wordpress.org/Shortcode_API
https://code.tutsplus.com/tutorials/wordpress-shortcodes-the-right-way–wp-17165
http://www.elegantthemes.com/blog/tips-tricks/how-to-create-shortcodes-in-wordpress
http://www.smashingmagazine.com/2012/05/01/wordpress-shortcodes-complete-guide/Thanks.
December 22, 2014 at 3:35 pm #169179Thanks for the links, however after looking at them and after attempting to understand, this is far from my understanding.
Is it possible to just show two short codes combined. ThanksDecember 22, 2014 at 4:07 pm #169221OK, I’ve been trying and this is what I came up with that seems to work, however I have some inconsistencies, for instance in the line: add_shortcode(‘custom_shortcode_logo’, ‘custom_shortcode’);
which works, then on the second one there is:
add_shortcode(‘full_logo’, ‘full_logo’);notice that the second ones name is repeated perfectly where the first one is different but does work.
SO my guess is this is sloppy and shouldn’t be.
So, can someone tell me the proper way to code this and or is there a shorter way to do multiple short codes using the below example:// Custom Shortcode – I added
// =============================================================================function custom_shortcode() {
$output = ‘Website Name<span style=”color: #ff0000; line-height: 10px; vertical-align: middle; letter-spacing: -1px;”>)</span>;
return $output;
}add_filter(‘init’, ‘add_custom_shortcode’);
function add_custom_shortcode() {
add_shortcode(‘custom_shortcode_logo’, ‘custom_shortcode’);
}function full_logo() {
$output = ‘Website Name<span style=”color: #ff0000; line-height: 10px; vertical-align: middle; letter-spacing: -1px;”>Logo</span>;
return $output;
}add_filter(‘init’, ‘add_full_logo’);
function add_full_logo() {
add_shortcode(‘full_logo’, ‘full_logo’);
}function logo+() {
$output = ‘Website Name<span style=”color: #ff0000; line-height: 10px; vertical-align: middle; letter-spacing: -1px;”>Logo+</span>;
return $output;
}add_filter(‘init’, ‘add_logo+’);
function add_logo+() {
add_shortcode(‘logo+’, ‘logo+’);
}Thank You
December 22, 2014 at 4:43 pm #169266SORRY, Please disregard the previous example, here is the corrected one.
*By the way if there is a way that I could have deleted the above post please let me know.// Custom Shortcode – added
// =============================================================================function custom_shortcode() {
$output = ‘Website Name<span style=”color: #ff0000; line-height: 10px; vertical-align: middle; letter-spacing: -1px;”>Logo</span>;
return $output;
}add_filter(‘init’, ‘add_custom_shortcode’);
function add_custom_shortcode() {
add_shortcode(‘custom_shortcode_logo’, ‘custom_shortcode’);
}function full_logo() {
$output = ‘Website Name<span style=”color: #ff0000; line-height: 10px; vertical-align: middle; letter-spacing: -1px;”>Logo</span>;
return $output;
}add_filter(‘init’, ‘add_full_logo’);
function add_full_logo() {
add_shortcode(‘full_logo’, ‘full_logo’);
}function logo() {
$output = ‘<span style=”color: #ff0000; line-height: 10px; vertical-align: middle; letter-spacing: -1px;”>Logo</span>;
return $output;
}add_filter(‘init’, ‘add_logo’);
function add_logo() {
add_shortcode(‘logo’, ‘logo’);
}function logoplus() {
$output = ‘Website Name<span style=”color: #ff0000; line-height: 10px; vertical-align: middle; letter-spacing: -1px;”>Logoplus</span>’;
return $output;
}add_filter(‘init’, ‘add_logoplus’);
function add_logoplus() {
add_shortcode(‘logoplus’, ‘logoplus’);
}December 23, 2014 at 2:09 am #169609Glad you’ve sorted it out. 🙂
December 23, 2014 at 8:12 pm #170420As mentioned:
“So, can someone tell me the proper way to code this and or is there a shorter way to do multiple short codes using the below example:” post# #169266 12/22/14 4:43pm
ThanksDecember 24, 2014 at 12:02 am #170532Hey there,
Sorry for the confusion. We’d love to help you with your concern however, your request falls beyond the scope of our support since creating shortcodes is not part of X. We can only give you an example.
You might want to contact our trusted partners who caters X setup and customization needs. Please see https://theme.co/x/member/custom-development/.
Thank you for understanding.
-
AuthorPosts