happy I’m sure this should help

Shortcode issues caused by extra HTML tags

I've had a few comments on the forum and via email regarding shortcodes not working, and many times it's been due to additional HTML tags that the WordPress editor has added to the shortcode. I've even had this issue on my own testing blogs, so I thought I'd bring this up here to let you know how to avoid this same issue.

here's the scenario:

you type or copy and paste something like this:
[idx-listings city="Laguna Beach" orderby="Price" orderdir="DESC" count="20"]
..then you go back and change the city, or maybe copy/paste this into the code:
maxprice="600000"
...and next thing you know, your shortcode does not produce results.

So while there many be many reasons why the code is not working (misspelling, bad search criteria, an extra space or two, or simply no results), quite a few times the culprit is the WordPress editor itself. Anytime you edit the shortcode in the WordPress editor, especially when you are copy and pasting segments from various sources to form a single line of shortcode, it's possible WordPress will add <span>, <font> or other tags around each segment you add to the code.

When this happens, my otherwise coolio shortcode above might end up looking something like this:

[idx-listings city="Laguna Beach" </span><span>maxprice="600000"</span><span>orderby="Price" orderdir="DESC" count="20"]


...which will not product results due to the extra tags splitting up the code.

So if you are one of the users that are regularly having this issue, and don't want to make a habit of manually removing those extra tags WordPress is adding, I'd suggest you either:
  • edit your shortcode in Notepad or someother program, then paste the entire line of shortcode into WordPress when it's assembled
  • or get in the habit of manually typing out the entire shortcode you want each time (vs. copy and pasting parts together)


We are still working on that promised neat-o tool that will write the shortcodes for you -- and that should address this issue once and for all -- but in the meantime this should help!
1 person has
this question
+1
Reply