Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #166778

    bearthedog
    Participant

    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

    #167011

    Zeshan
    Member

    Hi 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!

    #168011

    bearthedog
    Participant

    That 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?

    #168449

    Christian
    Moderator
    #169179

    bearthedog
    Participant

    Thanks 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. Thanks

    #169221

    bearthedog
    Participant

    OK, 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

    #169266

    bearthedog
    Participant

    SORRY, 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’);
    }

    #169609

    Christian
    Moderator

    Glad you’ve sorted it out. 🙂

    #170420

    bearthedog
    Participant

    As 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
    Thanks

    #170532

    Christian
    Moderator

    Hey 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.