Place shortcode inside ad field

Posted in: Newspaper
Post count: 4

Hello,
Do you know if there is anyway to add a shortcode of the WordPress inside the ad field?
Also, I would like to know if there is any change of calling a single post inside ad field.
Thank you.

Post count: 4

Wow…
I find the solution by myself!!!
I just putted the shortcode inside the field and it worked.
Disclaimer: I was using bad coded shortcode and did not worked the first time.

But to make this topic a little bit useful I am giving you the way I used to insert a single post’s content inside the ad field.
The reason to do such a thing is that it makes it very easy for a non tech user to manage custom ads by simply changing the content of a specific post (adding one linked image).

I just putted this code in the functions.php of the theme:
function show_custom_banner($atts) {
$queried_post = get_post($atts[‘post_id’]);
$content = $queried_post->post_content;
$content = apply_filters(‘the_content’, $content);
$content = str_replace(‘]]>’, ‘]]>’, $content);
return $content;
}
add_shortcode(‘my-banner’, ‘show_custom_banner’);

Then I was able to call any post content wherever I wanted, including the ad fields of your theme:
[my-banner post_id=”1″]

Thank you.

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newspaper’ is closed to new topics and replies.