Closed fabarea closed 1 year ago
Ah, it seems I was confused. Meanwhile, I noticed the Shortcut facade that can be used to register new shortcuts. I haven't played yet, but I bet that is the way to register shortcodes.
\WpStarter\Wordpress\Facades\Shortcode::add()
It seems that registering more than one shortcode is not possible, or at least it is not working for me.
Let's consider a scenario where we declare two shortcodes in the
routes/wp.php
file. For simplicity, we intentionally bind both shortcodes to the same controller.Route::get('welcome-shortcode', [\App\Http\Controllers\WelcomeController::class, 'shortcode']); Route::get('foo-shortcode', [\App\Http\Controllers\WelcomeController::class, 'shortcode']);
Now, on any WordPress page, let's declare two shortcodes as follows:
[welcome-shortcode]
and[foo-shortcode]
. Only the first shortcode is interpreted by me. The other stay as not "interpreted" (e.g. [foo-shortcode]) We can experiment by swapping the routes inroutes/wp.php
, and we'll observe the shortcodes interpretation.Am I missing a point?
Thanks BTW by your great work!
This feature called shortcode routing. You will use shortcode to route instead of path, then that single shortcode per route
It seems that registering more than one shortcode is not possible, or at least it is not working for me.
Let's consider a scenario where we declare two shortcodes in the
routes/wp.php
file. For simplicity, we intentionally bind both shortcodes to the same controller.Now, on any WordPress page, let's declare two shortcodes as follows:
[welcome-shortcode]
and[foo-shortcode]
. Only the first shortcode is interpreted by me. The other stay as not "interpreted" (e.g. [foo-shortcode]) We can experiment by swapping the routes inroutes/wp.php
, and we'll observe the shortcodes interpretation.Am I missing a point?
Thanks BTW by your great work!