Skip Navigation

[Résolu] WordPress standard output for one shortcode

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 4 réponses, has 2 voix.

Last updated by Eric Il y a 8 années et 2 mois.

Assigned support staff: Luo Yang.

Auteur
Publications
#109538

Hello,

I have a Content Template that is set for "Raw output," which works exactly how I need it to for all my custom fields and the containing markup. BUT, I'm going to need just one WYSIWYG custom field that uses the standard WordPress output. Is it possible to declare that in the shortcode?

Thanks,
Eric

#109644

Luo Yang
Supporter

Languages: Anglais (English ) Chinois simplifié (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hi Eric,

Could you decribe the question with more details?

Raw output
All Types custom fields have an optional ‘raw’ display mode. When you set “raw??=>??true??, Types outputs the value of the field from the database, without any processing. This means that any other attributes will be ignored.
https://toolset.com/documentation/functions/

Hope it help

#109663

Hi Luoy,

In my Content Template, in the Content Template Settings box, I chose the option: "Raw output - only resolve shortcodes without adding line breaks or paragraphs." That way I wouldn't have to worry about WordPress inserting its own p tags and breaks. Here's my code, so far:

<div class="main-image">
  [types field="main-photo" proportional="true" align="none"][/types]
  <div class="quotation [types field="main-photo-caption-alignment"][/types]">
    <span>[types field="main-photo-caption" separator="</span><span>"][/types]</span>
  </div>
</div>
<div class="story">
  <h2>[types field="headline"][/types]</h2>
  <p>[types field="first-paragraph"][/types]</p>
  [wpv-if types field="wpcf-video-url" evaluate="!empty($video_url)"]
	<div class="video caption">
		<iframe  width="690" height="388" src="[types field="video-url"][/types]" frameborder="0" allowfullscreen></iframe>
		[wpv-if types field="wpcf-video-caption" evaluate="!empty($video_caption)"]
      <div class="caption-text"><p>[types field="video-caption"][/types]</p></div>
		[/wpv-if]
  	</div>
  [/wpv-if]
  [types field="free-form-content" class="" style=""][/types]
</div>

Notice the last shortcode there called "free-form-content." That's a WYSIWYG field. I'd like that one field to use the standard WordPress output, automatically adding the p tags and breaks when my client enters content in the editor. The way this particular post type is designed, the main image, headline, first paragraph, and video (if supplied) will be completely uniform across all posts. Everything beneath the video, however, can be custom content. I'm trying to make content input as easy as possible.

#109760

Luo Yang
Supporter

Languages: Anglais (English ) Chinois simplifié (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

I have test in my localhost, you are right, as you mentioned above, it will remove p tags and breaks.

I suggest you try this:
1) create another view template, for example "free-form-content template", put shortcode into it
[types field="free-form-content" class="" style=""][/types]
set it as "Normal WordPress output"
2) replace the the codes in your view template from:
[types field="free-form-content" class="" style=""][/types]
to:
[wpv-post-body view_template="free-form-content template"]

#114839

I ended up using WordPress standard output and simply removing line breaks where necessary. Made for less-than-pretty markup, but the page output looks fine.
Thanks!
Eric