Congrats, WP 4.2.3 Workarounds, and a Suggestion
-
Hi Eliot,
Firstly, congratulations on getting CCS back into the repository ?? Glad it didn’t take too long. That must have been nerve-racking for you!
So, I’m back because I managed to resolve every issue that the WP 4.2.3 update caused, and I thought some people might find my solutions helpful. Here are various examples of the changes I had to make to get my code to work:
1) An infinite taxonomy loop using
for each
:Stopped working (started returning the id of the current page instead of the one called by the loop):
[for each=category] Some HTML [each title] (<a href="/wp-admin/post.php?post=[each id]&action=edit">edit</a>) [/for]
Works!
[pass taxonomy_loop="category"] Some HTML {TERM_NAME} (<a href="/wp-admin/post.php?post={TERM_ID}&action=edit">edit</a>) [/pass]
2) An infinite post/page loop:
Stopped working (started returning the id of the current page instead of the one called by the loop):
[loop type="post"] Some HTML [field title-link] (<a href="/wp-admin/post.php?post=[field id]&action=edit">edit</a>) [/loop]
Works!
[loop type="post"] Some HTML [field title-link] ([field edit-link]) [/loop]
NB:
edit-link
isn’t listed in the documentation — could this be added to the predefined fields section?Suggestion:
edit-link
outputs the post/page title, but as per my example above, that can be redundant in certain use cases. Would it be possible to enable something like[field edit-link link_text="Edit"]
, wherelink_text
would be optional and the current output would be default?3) A post/page loop by taxonomy:
Stopped working (started returning the first few characters of the actual shortcode as the url, instead of the url called by the loop):
[loop type="post" taxonomy="AAA" term="BBB" compare="not"] Some HTML <h3>[content field="title"]</h3> More fields and HTML <a href="[content field="url"]">Read <span class="screen-reader-text">[content field="title"]</span><span aria-hidden="true">this</span> now</a> [/loop]
Works!
[loop type="post" taxonomy="AAA" term="BBB" compare="not" fields="url"] Some HTML <h3>[content field="title"]</h3> More fields and HTML <a href="{URL}">Read <span class="screen-reader-text">[content field="title"]</span><span aria-hidden="true">this</span> now</a> [/loop]
4) A post/page loop by ID:
Stopped working (started returning the first few characters of the actual shortcode as the url, instead of the url called by the loop):
[loop type="post" id="###"] Some HTML <h3>[content field="title"]</h3> Some more fields and HTML... <a href='[content field="url"]'>Read <span class="screen-reader-text">[content field="title"]</span><span aria-hidden="true">this</span> now</a> [/loop]
Works!
[loop type="post" id="###"] Some HTML <h3>[content field="title"]</h3> Some more fields and HTML... <a href='[content type="post" id="###" field="url"]'>Read <span class="screen-reader-text">[content field="title"]</span><span aria-hidden="true">this</span> now</a> [/loop]
5) Another post/page loop by taxonomy:
Stopped working (the link worked fine but none of the css):
[loop type="post" taxonomy="AAA" term="BBB"] <div class="something"> <h2 class="example">[content field="title-link"]</h2> [field image size="small" image_class="alignleft"] <p class="item">[content field="excerpt"]</p> </div> [/loop]
Works!
[loop type="post" taxonomy="AAA" term="BBB"] <div class='something'> <h2 class='example'>[content field="title-link"]</h2> [field image size="small" image_class="alignleft"] <p class='item'>[content field="excerpt"]</p> </div> [/loop]
NB: All HTML within the loop shortcode must use single quotes if the loop and content shortcodes use double quotes. Or, vice versa.
———
Final Suggestion: Following the train of thought of my earlier idea, it would perhaps be quite useful to have something like
[content field="link" link_text="XXX"]
to avoid the need to use<a href="[content field="url"]">Text</a>
.CCS is so flexible that with a little bit of brain work, it was fairly easy to figure out workarounds for the issues created by the WP 4.2.3 update. In most cases, as can probably be gathered from examining the above examples, there were multiple solutions available. I hope this info is useful to someone ??
- The topic ‘Congrats, WP 4.2.3 Workarounds, and a Suggestion’ is closed to new replies.