Add shortcode to button
-
Is it possible to use the “add favorite” shortcode in a button?
I use Elementor and tried adding the shortcode with and without style, without any success.
-
Hello, @yannicksg
Sorry. I’ve never used Elementor, so I don’t know about compatibility, but can shortcodes be used in that plugin?
URLs that may be relevant
https://ww.wp.xz.cn/support/topic/shortcodes-and-elementor-2/
https://elementor.com/help/dynamic-shortcode-pro/Thanks for the quick reply!
Yes, shortcodes can be used in a button. But the button recognizes the shortcode as a link: https://www.loom.com/share/18b7f3f4685f4e4ab3c38d619127330c
Another quick question, is it possible to use a WordPress Function in the shortcode, so we don´t have to add each page id manually?
Hi, @yannicksg
Yes, you can use WordPress functions for the shortcode. You can set the post ID dynamically.
However, I don’t know if you can do that in Elementor.- Can you try to put just the shortcode in an empty block?
- Or does it work if I enter it in a regular block editor shortcode block?
Also, the
style=''would probably be the default style.
If you don’t want the default style, put some name likestyle='none'.Hello @takashimatsuyama,
the shortcode works with a simple shortcode block from Elementor, yes. I think it is an issue with Elementor, that they are trying to open Shortcodes as a link, when you add them to a button.
I also managed to add the Post ID dynamically and and to the Sonaar Music Player. Thank you!
One last question, is there a list of style codes I can work with? I try to have the preview images in 400×400 size.
Hi, @yannicksg
Thank you for your review.
There are two styles: default or write your own.
Modify the default style
shortcode:[ccc_my_favorite_list_results]#ccc-my_favorite-list[data-ccc_my_favorites-list-style="1"] .list-ccc_favorite { width: 400px; } #ccc-my_favorite-list[data-ccc_my_favorites-list-style="1"] .list-ccc_favorite .img-post-thumbnail { padding-bottom: 100%; }Style your own
shortcode:[ccc_my_favorite_list_results style="your_style_name"]#ccc-my_favorite-list[data-ccc_my_favorites-list-style="your_style_name"] { ... }Please, try it.
Also, you can customize the list view.
shortcode:
[ccc_my_favorite_list_custom_template]Please see the related topic for usage.
Thanks
Hi, @yannicksg
I’m glad to hear that.
Thank you, too.I want to add to favourite button shortcode in my maxbutton plugin in my site http://kitchendimes.com I am using generatepress theme.
The topic ‘Add shortcode to button’ is closed to new replies.

