0

I know i'll get bombarded for this question but the truth is I researched and found nothing.

I'm not a WP expert or anything, i just found my ways to design WP themes. But there is something i never got straight.

WHY IN HECK SHORT-CODES DON'T WORK FOR ME.

When i mean shortcodes i mean the ones provided by a plugin, not created by myself what it makes it probably dumber.

Example:

I write in a page or a post:

[audio src="http://my_url.com/my_track.mp3"]

I see the audio controls in the WP editor, but in the browser i see the text, not the audio.

2nd example:

I just tried to use a WPForms shortcode in order to display a contact form.... I see the text, not what the shortcode should be doing.

Up to this point my solution if I need to run a shortcode is creating a page/post template and do:

<?php echo do_shortcode('[My_shortcode]'); ?>

Thanks a lot and sorry for the dumbest question.

  • what theme are you using, and what is the code in the theme to display the content? do shortcodes work if you switch to the default theme Twenty Seventeen, and if you add the shortcode into the content of a post or static page? – Michael Aug 18 '17 at 2:04
0

It looks like theme issue. Switch to default WordPress theme and check it. I have tested it on WordPress Twenty Seventeen theme.

For testing:

1) Add below code in theme functions.php

// Sample shortcode [testme]
function testme_cb( $atts ) {
    return 'Working? Maybe.';
}
add_shortcode( 'testme', 'testme_cb' );

// Enable shortcodes in text widgets
add_filter('widget_text','do_shortcode');

2) Goto Appearance -> Widgets and add shortcode [testme] in Text Widget.

Shortcode


3) Check it on frontend.

Front End

  • Thanks for your response, the shortcodes works in a default theme, not in mine (image captions for instance). What could i have done to disable shortocdes in my theme??? or do i have to enable them??? – Marcos Di Paolo Aug 30 '17 at 3:44
  • EDIT: OMG!!! i was using echo get_the_content() instead of the_content() – Marcos Di Paolo Aug 30 '17 at 4:08
1

Take a look at the syntax of do_shortcode (here: https://developer.wordpress.org/reference/functions/do_shortcode/ ), and the examples shown on that page.

Also, this page https://codex.wordpress.org/Shortcode_API on how to use shortcodes in your plugin.

  • But my problem isn't with the do_shortcode in my code editor, it is using shortcodes in post and pages in the WP dashboard. – Marcos Di Paolo Aug 18 '17 at 3:30
  • Assuming that the shortcode 'code' is set up properly, then putting [my_short_code] in the post/page text area should work. – Rick Hellewell Aug 18 '17 at 17:41
0

[audio src="http://my_url.com/my_track.mp3"] add shortcode into the content of a post or page <?php echo do_shortcode('[My_shortcode]'); ?> put code in file .php eg:content.php,single-post.php where you want to display You should learn how to make shortcode and using shortcode in wordpress page clearly

  • I already know that bud. Read the question again. My problem lays in the dashboard, not in php. – Marcos Di Paolo Aug 18 '17 at 3:32
  • what theme are you using,reading the structure ur themes and please put [yourshortcode] or do_shortcode correctly – Rei Aug 20 '17 at 7:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.