How To Display Html In A Shortcode For A Specific Page –
The Page Is Woocommerce Shop Page
I addet the short code in widget and is not showing
need to show only for specific page
here is the code [rj_mysh]
function rj_mysh_shortcode() {
if(is_page(11762)) {
$html = '<a href="example.com/script.php?id="></a>;
return $html;
}
}
add_shortcode('rj_mysh', 'rj_mysh_shortcode');
2
Answers
The code looks like it will only show on page id = 11762.
If it’s in a widget, it may not know it’s on page 11762, so it doesn’t display.
It looks like you only want that item to appear in the widget area of page 11762. That’s a bit tricky.
Solutions:
First of all, we are NOT gonna input html via the function.php file, never! (If you do I kill baby Yoda!). If you want to have real control the following is the best way.
The right way to do it is to paste our custom "function" into the
page-shop.php
file.In your theme file, you should have a file called
page-shop.php
, upon opening it, bellow the header (anywhere you want, adapt it to the design) add the following:Hope that will help