Support » Plugin: Custom Content Type Manager » [Plugin: Custom Content Type Manager] Using shortcode in text area

  • Resolved jumust

    (@jumust)


    Hi,
    I’m using some shortcodes that I created with a plugin to display few icons.

    I set up with CCTM some custom fields as text-area and the default output filter as None (raw)

    If I add all those shortcodes to the default editor of WordPress they display correctly the image but if I add them in the text-area of CCTM they show up with the shortcode.
    If I was not clear I’m adding here a screenshot http://screencast.com/t/4tuTAK9Vb

    Also if I push the button shortcode in the HTML editor it doesn’t even work, only works with default WP editor

    Please advice as I set up many Custom fields with your plugin and now it’s definitely necessary to use shortcode within them. I might want to ask you for a custom work if it was not included in your plugin as I think this option should be obvious.

    Thanks a lot!

    http://wordpress.org/extend/plugins/custom-content-type-manager/

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Contributor fireproofsocks

    (@fireproofsocks)

    By default, WordPress parses shortcodes ONLY in the main content block. If you use shortcodes in your own WYSIWYG field (or anywhere else), you’ll need to use the “do_shortcode” filter: http://code.google.com/p/wordpress-custom-content-type-manager/wiki/do_shortcode_OutputFilter

    Thanks!I’m trying to figure that out with the code I’m using. I built this piece of code basically with your suggestion at that time, now can’t understand how to edit it with the shortcode function, it’s breaking the page

    <?php
    								print wpautop( get_custom_field('contatti:wrapper'
    								  , '<div class="one_half" style="margin-bottom: 25px;">
    								  <hr class="section" /><span class="tag_section">Contatti</span><hr class="section" /><div style="margin-top:25px;">[+content+]</div>
     								 </div>'
    									 )
    								);
    							?>

    @fireproofsocks any idea what are the steps I need to get it working.
    Now I can’t use shortcode in WYSIWYG field created with your plugin

    What I wanna do is to have also text in the WYSIWYG and not only shortcode.

    Thanks a lot!

    Plugin Contributor fireproofsocks

    (@fireproofsocks)

    By default, WordPress does not parse shortcodes anywhere EXCEPT in the main content block. You need to use the do_shortcode() function to parse shortcodes elsewhere. See the do_shortcode filter: http://code.google.com/p/wordpress-custom-content-type-manager/wiki/do_shortcode_OutputFilter

    In your example, you’re using the “wrapper” output filter and some custom WordPress modifications… so it’s kinda a mess. Either use the CCTM’s output filter or use WP’s do_shortcode function: http://codex.wordpress.org/Function_Reference/do_shortcode

    Thanks! I’m not expert and I built that code earlier asking in this forum suggestions because I don’t know how to write that code actually.

    The thing I need is that the custom field disappear on the website if there is not content posted there in the admin, I remember maybe that someone told me to add print wpautop….so I don’t even know why I put it there.

    Than I added my class and div, easier for me.

    So what should I use to get shortcode working and make the field disappear if there is not content?

    Plugin Contributor fireproofsocks

    (@fireproofsocks)

    Do something like this:

    <?php
    	print_custom_field('contatti:wrapper:do_shortcode'
    	  , '<div style="margin-top:25px;">[+content+]</div>');
    ?>

    You can chain output filters (see http://code.google.com/p/wordpress-custom-content-type-manager/wiki/OutputFilters) so I just added the do_shortcode filter after the wrapper filter.

    Or if you wanted to use WP’s raw function:

    <?php
    	do_shortcode(get_custom_field('contatti:wrapper'
    	  , '<div style="margin-top:25px;">[+content+]</div>')
    	);
    ?>

    Perfect it works thanks!

    Just curious as to how to get do_shortcode to work in my textarea (using the Editor option on Custom Content Type) the WP documentation on the subject is pretty sparse. I tried
    <?php echo do_shortcode( 'ecpt_My_Field_Name' ) ?> to no avail.

    Thank you!

    Plugin Contributor fireproofsocks

    (@fireproofsocks)

    WP’s do_shortcode function has caused me many headaches. But you need to run it on a string containing a shortcode, e.g.

    <?php print do_shortcode( get_custom_field('my_custom_field') ); ?>

    Is it possible for WP 3.4.2 to not understand get_custom_field? I feel like I have tried this and gotten an error that get_custom_field does not exist.

    Is this because I need to define get_custom_field in my theme functions?

    Plugin Contributor fireproofsocks

    (@fireproofsocks)

    If you have installed CCTM and activated it, then that function gets defined. Its includes/functions.php file should be loaded during every page request. You can check whether it’s defined using function_exists: http://php.net/manual/en/function.function-exists.php

    To debug your output, try printing the output of the function.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘[Plugin: Custom Content Type Manager] Using shortcode in text area’ is closed to new replies.