Is it just me with shortcodes
-
-
I hate short codes – is it just me?
I have been developing sites in wordpress for around 10 years and for the most part it’s a thing of beauty. However shortcodes cause me more head scratching than any other feature. My hunch is that this is not wordpress.org’s fault but the fault of the fact that people have taken a very useful feature and bent it to their will and therby caused headaches. I think I’m right in thinking that the point of shortcodes was to take the heavy lifting out of creating content away from your post or page and tehn transferring it. A photogallery being a good example.
The problem arises when theme developers use them in a way that i don’t think they were really intended and so make customisation much more difficult. Let me give you an example:
I have a client who want to hide the phone number from the top of his web page whilst in covid 19 lockdownThe theme has created this header feature in shortcode:
[vt_address_infos][vt_address_info address_style=”style-one” info_icon=”fa fa-phone” info_main_text=” CONTACT PHONE ” info_sec_text=”020 3884 1414″ info_sec_text_link=”tel:02038841414″][vt_address_info address_style=”style-one” info_icon=”fa fa-clock-o” info_main_text=”OPEN HOURS” info_sec_text=”24hrs / 7 Days”][vt_address_info address_style=”style-one” info_icon=”fa fa-map-marker” info_main_text=”ADDRESS ” info_sec_text=”91-93 Buckingham Palace Road, London”][/vt_address_infos]As this is a temporary removal of content I want to use ‘display:none’
Here’s the front end code:
CONTACT PHONE </span>020 3884 1414</div></div><div class=”contact-item “><div class=”pull-left”><i class=”fa fa-clock-o” style=””></i></div><div class=”contact-info”><span style=””>OPEN HOURS</span><p style=””>24hrs / 7 Days</p></div></div><div class=”contact-item “><div class=”pull-left”><i class=”fa fa-map-marker” style=””></i></div><div class=”contact-info”><span style=””>ADDRESS </span><p style=””>91-93 Buckingham Palace Road, London</p></div></div></div></div>The issue is that I cannot assign the property display:none to any of the selectors because no selector is specifically assigned to the telephone number of the shortcode. If I assign it to the ones that exist (“contact-details”, “contact-item “, “pull-left” it will hide ALL the items in the shortcode.
If this was regular html I could simply wrap the phone element in a block level element, assign a class and add display:none. Trouble is, you can’t assign classes in shortcode – it just strips them out.
I understand from online research that you can ‘tamper’ with the core files. I make a point of NEVER doing this. Theme core elements are bad enough without amateurs (albeit a reasonably enlightened one) editing it.
My rather clumsy point is that shortcodes are great for adding elements on a page that are customisable elsewhere but lousy for elements that can only be customised inline.
:(
-
Hi there!
What’s the address of the site you’re working on?
Please note that these forums are for WordPress.com hosted sites only. If your site is using the open-source WordPress.org software, we won’t be able to help you out and you’ll want to seek help at these forums:
- The topic ‘Is it just me with shortcodes’ is closed to new replies.