Hi,
I am trying to create my own module from scratch : When I click on “Add element,” not all the options that are available when creating a page appear. I am looking for a way to insert a custom shortcode. There are “Common page elements shortcodes” and “Multipurpose shortcodes,” but I can’t seem to add my shortcode to the available elements. How can I insert my own shortcode into my module?
Thank you in advance.
Yohann
Thank you for your response.
Maybe I can modify an existing element to make it use my shortcode? My goal is to display dynamic content in addition to the default content that will appear in this module (title, excerpt, image, date) inside a loop
For example, the “Column Title” element from “Multipurpose shortcodes”—where can I find the PHP file or code to modify it? I have tried searching in td-composer folder without success.
Thank you
Hello,
The modules are not working like that; those are for posts and custom post types. You can not add shortcodes on the modules because those get the content of the post type set and show the details of the elements you have added to create the module.
Thank you!
So how can you add a third party shortcode in tagdiv composer?
Hi @bnrbranding,
A shortcode can be inserted also by using the element called “Column text” or “Text with title”. “Column text” and “text with title” elements have a button called “edit content” and if you click on that button, the WP Editor will open, and you can add some text/code/shortcode there. Close the WP Editor from X, save the changes from Composer and view the page to see the changes.
But you can not add it to the module template.
Thank you!
To continue this thread, here’s how I managed to achieve what I wanted.
In my custom module, I added an element of the “Column Title” type from the “Multipurpose shortcode” category, and in the title, I placed “foobar”.
Then, in the plugin file td-composer : td_multi-purpose/shortcodes/tdm_block_title_simplified.php,
I modified line 56 with the variable $buffy.
If I detect the title “foobar”, then I use do_shortcode() and call my function to add a dynamic element.
This works on the front-end, no regression, BUT it remains unstable when editing in the back-office. I will need to add a condition: if back-office, do not load do_shortcode(). Nothing difficult, but not urgent for me.
The code is well-documented, and for future updates, I’ll just need to be careful.