We're merging with GenerateBlocks! Learn more here.

[Resolved] PHP version of shortcodes with multiple parameters

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support PHP version of shortcodes with multiple parameters

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #24462

    Dear WP team,

    In short: How to create a php snippet to display a WPSP list filtered with additional custom fields?

    I’m using a shortcode to present a WPSP list but would ask for your help so it can be defined correctly via php instead. I’ve made a few attempts, without success.

    The shortcode includes several additional parameters, related to a custom field created with the ACF plugin to rank & order the posts. Since i need to filter and order the output in a specific way, i adjusted the shortcode as suggested by Tom here.

    The end result: [wp_show_posts id="1477" settings="meta_key=network-order&orderby=meta_value_num&order=ASC"]
    – where “1477 is my list’s Id and “network-order” is the custom-field’s name

    This works well but leads to a known problem: every time the page is edited anew, the “&” is replaced by “&”, breaking the functionality unless it’s manually cleaned. This has been (raised in another post, but the php equivalent was not indicated.

    Since this is for a client, the manual editing step might fail and i would prefer to implement a php snippet to go in the functions.php of the child theme (based on Generate Press Pro, if relevant). The shortcode goes inside a container block (Generate Blocks, if relevant – i think you can spot a trend in user preferences here ;))

    If doable, how should the php snippet look like?

    Thank you in advance for your assistance!


    The example above was cleaned, funnily enough 🙂

    Just for clarity: The “&” is replaced by & (“&” followed by the ampersand HTML code). This leads to the problem described above. I understand this is not WPSP’s flaw, rather WordPress’ beahviour.

    Best regards.



    You can try wrapping the WPSP shortcode within another shortcode as Tom suggested here:


    His reply includes a snippet for making shortcodes incase you need it.


    Hi Elvin,

    Thanks for the link. That was all i needed and it worked perfectly!

    Great support, as always.

    Wish you all a good holiday season and start of 2021!



    Nice one! Glad you found it useful. No problem. 🙂

    Stay safe. 😀

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.