This repository contains the latest development version.
For production use, please see the offical WordPress plugin page.
This plugin is no longer in active development.
Please use the next-generation template system, Loops & Logic.
Custom Content Shortcode
This repository contains the latest development version.
For production use, please see the offical WordPress plugin page.
This plugin is no longer in active development.
Please use the next-generation template system, Loops & Logic.
I'm using CCS extensively in my site... it is absolutely fantastic.
I have a lot of custom post types with ACF fields. In particular, I have one post type that contains relationships to another post type. Right now, I've written some php to handle it in the template file but I'd prefer to use the [related] shortcode.
The only thing is the related posts are returned in the order they're stored and I'd like to alphabetize them by title.
I've looked at the acf module and it's waaay beyond my level of php :)
There are a bunch of PHP warnings when using PHP8 that fill the logs even when CC is just activated and you are not even using it.
[22-Dec-2021 17:39:44 UTC] PHP Deprecated: Required parameter $tag follows optional parameter $content in /Users/pross/Repos/custom-content-shortcode/includes/modules/if.php on line 1375
[22-Dec-2021 17:39:44 UTC] PHP Deprecated: Required parameter $tag follows optional parameter $content in /Users/pross/Repos/custom-content-shortcode/includes/modules/paging.php on line 92
[22-Dec-2021 17:39:46 UTC] PHP Deprecated: Required parameter $template follows optional parameter $parameters in /Users/pross/Repos/custom-content-shortcode/includes/core/loop.php on line 94
[22-Dec-2021 17:39:46 UTC] PHP Deprecated: Required parameter $between_row follows optional parameter $pad in /Users/pross/Repos/custom-content-shortcode/includes/core/loop.php on line 2639
[22-Dec-2021 17:39:46 UTC] PHP Deprecated: Required parameter $content follows optional parameter $atts in /Users/pross/Repos/custom-content-shortcode/includes/modules/comments.php on line 279
[22-Dec-2021 17:39:46 UTC] PHP Deprecated: Required parameter $shortcode_name follows optional parameter $content in /Users/pross/Repos/custom-content-shortcode/includes/modules/foreach.php on line 49
[22-Dec-2021 17:39:46 UTC] PHP Deprecated: Required parameter $shortcode_name follows optional parameter $content in /Users/pross/Repos/custom-content-shortcode/includes/modules/foreach.php on line 352
shortcode outputs extra whitespace for every line.
It would be useful if extra line breaks/double space etc between shortcode tags was removed from output
if i have a CCS like this:
[if check={COURSE_TYPE} value="new"][set type]new[/set][else][set type][/set][/if]
£[format decimals=0 point=. thousands=,]
[if check={TYPE} value="new"]
[global][data key="course-information-new" field="total_fees"][/global]
[else]
[global][data key="course-information" field="total_fees"][/global]
[/if]
[/format]
[/pass]
all of those lines create whitespace around the output
normally it's not a problem but when run through an HTML compressor on a line like this it'll end up stripping white space between words because of the extra whitespace from the shortcode
New Courses: [my_shortcode] Fees
will come out something like this after compression
New Courses:£1,000Fees
since the uncompressed HTML is actually something like
New Courses
£1,000
Fees
essentially I'd have to write it like this...
[if check={COURSE_TYPE} value="new"][set type]new[/set][else][set type][/set][/if]£[format decimals=0 point=. thousands=,][if check={TYPE} value="new"][global][data key="course-information-new" field="total_fees"][/global][else][global][data key="course-information" field="total_fees"][/global][/if][/format][/pass]
...which is hard to read
thanks
J
Hi @eliot-akira,
great plugin but I'm having to rely on a few workarounds for conditionals currently.
this is related to #10
I need to be able to show some html when a shortcode parameter is not passed. in part because there's no [if]
...[elseif]
...[elseif]
...[else]
...[/if]
structure that i can see?
anyway.. given the following two scenarios eg
[myshortcode param="foo"]
[myshortcode]
and the following meta shortcode logic:
[if check={PARAM} value="foo"]Foo[/if]
[if check={PARAM} value="bar"]Bar[/if]
<!-- this doesn't work -->
[if check={PARAM} value=""]Baz[/if]
I need the second shortcode to output "Baz" when no param
is passed
but this doesn't work either (see other issue)
[if exists]{PARAM}
[show]param was passed
[else]param wasn't passed
[/if]
if param is not passed as an empty string like [myshortcode param=""]
then {PARAM}
inside the [if...]
will just be the string "{PARAM}" and therefore exists and breaks the condition ie instead of it being empty it has the content {PARAM}
.
I have a workaround but there's a bug if param
value sent does not contain a space:
[if check={PARAM} value="{PARAM}"]
param not passed
[else]
{PARAM}
[/if]
using this code...
[myshortcode]
shows "param not passed" (expected)
[myshortcode param="foo"]
shows “param not passed” (fail, should show "foo")
[myshortcode param="foo bar"]
shows “foo bar” (expected)
in all instances:
value=empty
(or null)? (ideally something like [if check={PARAM} value=null]
[if not check={PARAM}]
etcparam
should parse accordingly to the correct value.. mostly it does except in that [if check]
as explainedthanks for any input
regards
J
I have a shortcode that starts with a note
[note]improve logic[/note]
and I call it from my php in a function in an array with
'total_fees' => do_shortcode('[total_fees_formatted course_type='.$course_type.']'),
when I run this i get the error
Non-static method CCS_Loop::shortcode_comment() should not be called statically
all my other CCS functions [global]
, [format]
, [if]
etc work fine
thanks
Hey There,
I'm not sure if you're looking for feature requests here, but I've got one! It would be to add count/start to acf related fields.
Otherwise thanks for the great plugin and cheers!
Jason
Hi,
you're trying to check $thousands
variable before it is assigned.
$thousands = !empty($atts['thousands']) ? ($thousands==='false' ? '' : $atts['thousands']) : '';
in includes\modules\format.php
this throws an error:
Undefined variable: thousands
(currently this means I have to turn debug off on my dev site to prevent from happening)
maybe you mean to check $atts['thousands']==='false'
?
thanks
J
This:
$[format decimals="0" point="." thousands=","][field price][/format]
..causes a warning:
Undefined variable thousands in includes/modules/format.php on line 158
For example, textarea name="custom-form[content]"
.
https://wordpress.org/support/topic/bug-with-form-fields-that-use-nameformcontent/
[if exists]{PARAM}
[show]The first parameter was passed
[else]The first parameter wasn't passed
[/if]
the else
only works correctly if i send as [myshortcode param=""]
if i just use [myshortcode]
then [if exists]
returns true.
thanks
J
[related location_select]
[pass field=menu_title]
[loop menu="{FIELD}" list=true li_class=custom_li_class]
[field title-link]
[/loop]
[/pass]
[/related]
This doesn't seem to be working. I've tried adding it to every shortcode in this setup. I've tried just class= and removing list=true. Can you help or explain how to add classes to fields? The [field title-link] needs to be able to have a class, but I just can't figure it out.
Such as repeater: https://wordpress.org/support/topic/fatal-error-using-repeater-colour/
see discussion here
https://wordpress.org/support/topic/accessing-multiple-value-from-a-custom-field/
it should be possible to create a custom field in wordpress multiple times with different values and then process this with [array myfield]
or [pass array=myfield]
I've noted some potential changes on that support thread
essentially get_post_meta
last parameter single=true
in the CCS plugin could theoretically be changed to false
to allow for this (this is standard behaviour https://www.wpbeginner.com/wp-tutorials/wordpress-custom-fields-101-tips-tricks-and-hacks/#multiplevalues)
thanks
J
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.