Support

Account

Home Forums Search Search Results for 'Wysiwyg'

Search Results for 'Wysiwyg'

reply

  • get_field() gets the value of the field. the_field() outputs the content of the field. Both functions format the value the same way, basically the same way that WP formats the value of the main content editor. For a WYSIWYG field, if you want to get the value without formatting the you need go do get_field('my_field', false, false). The second argument is the post ID, set to false it means the current post. The 3rd argument tells ACF not to format the value.

  • Looking at the documentation here it seems that maybe the problem is that I’m using get_field ?

    https://www.advancedcustomfields.com/resources/get_field/

    What’s the difference in output between get_field and the_field on a WYSIWYG field?

    I also see that that there is the ability to call the field without formatting by saying get_field(‘field_name’, false, false). Am I understanding that correctly?

  • I was thinking like this:
    image

    having looked at the documentation here: https://www.advancedcustomfields.com/resources/textarea/

    I think the thing I’m getting confused by is the difference between textarea and wysiwyg.

    Here’s the problem:

    I have a get_field php call inside of a p tag like this

    <p class="class-name"> get_field(etc etc); </p>

    And it outputs like this

    <p class=class-name> </>
    
    <p> 
     <ul>the content that I put into my field </ul>
       <li>content</li>
       <li>content</li>
       <li>content</li>
       <li>content</li>
     </p>
    
    <p> </p>

    Which is super ugly and no good.

  • I’m not 100% clear on what you’re looking for.

    What to you mean by:

    Normal WYSIWYG wordpress allows you when you first create the field to say whether or not you want it to put out HTML or just pure text.

    I don’t have any knowledge of adding a wysiwyg field in WP other than using ACF to do it, so any documentation you can point me to would probably be helpful.

    ACF4 uses a different editor than the main WP editor. ACF5 uses the same editor. There is a significant difference between these two versions of the plugin. The developer is working on releasing a free version of ACF to WP some time this year.

  • Someone has created a fork of my plugin that does wysiwyg fields here https://github.com/puntonero/acf-input-counter. I have not incorporated it into my because I fell it is outside the scope of what I set out to do.

  • I’m having a bit different issue with this filter. My validation is working, but I’m using this with a front end acf_form and when the validation error triggers it’s displaying the message on the full page and not as a error on the field. Is that expected? I am using this on a WYSIWYG field if that makes any difference.

  • What happens if you get the unformatted value from the ACF WYSIWYG and then apply the_content filters to it?

    Example:

    
    $value = get_field('wysiwyg');
    $value = apply_filters('the_content', $value);
    echo $value;
    
  • I have done some further testing to see where the problem arrises.

    1. From https://www.imagely.com/docs/nextgen-gallery-shortcodes/#gist21867672 take the shortcode [ngg_images gallery_ids=1 display_type=photocrati-nextgen_basic_thumbnails disable_pagination=1 images_per_page=1 show_all_in_lightbox=1] and paste it into an ACF field with a WYSIWIG editor
    2. preview: gallery will show fine
    3. edit the Nextgen gallery by clicking on the pen icon in the Nextgen gallery icon in your WYSIWIG content
    4. change which gallery should be displayed and hit ‘Insert Displayed Gallery’
    5. preview the post. The error If you're seeing this, it's because the gallery type you selected has not provided a template of it's own. is displayed
    6. now compare the shortcode above with the current shortcode: it has many differences

    Above shortcode after editing the gallery to be displayed using the ‘edit-gallery’ button:

    
    [ngg_images source="galleries" container_ids="2" display_type="photocrati-nextgen_basic_thumbnails" override_thumbnail_settings="0" thumbnail_width="240" thumbnail_height="160" thumbnail_crop="1" images_per_page="1" number_of_columns="0" ajax_pagination="0" show_all_in_lightbox="1" use_imagebrowser_effect="0" show_slideshow_link="0" slideshow_link_text="[Show slideshow]" order_by="sortorder" order_direction="ASC" returns="included" maximum_entity_count="500"]
    

    Related issues: https://support.advancedcustomfields.com/forums/topic/wysiwyg-field-not-displaying-nextgen-gallery-2/

  • Unformulated does not refer to text formatting. For most fields that store simple text values (all of the basic fields) there is no difference between formatted and formatted. Unformatted in the ACF sense means that the value is returned exactly as it is stored in the database. For example, shortcodes and other filters will not be run on a WYSIWYG field, or a relationship field will return an array of post IDs instead of returning post objects. With a text field, the value you see is what is stored in the DB.

  • Only the WYSIWYG field will automatically run shortcodes. Look at this page which has an explanation of how to have other fields run shortcodes https://www.advancedcustomfields.com/resources/acfformat_value/

  • I have done this very thing for a client (but for different reasons)…

    Here’s the code I used to display a WYSIWYG custom field in the attributes list:

    add_filter( 'woocommerce_get_product_attributes', 'ariel_display_recordings_attribute', 20 );
    function ariel_display_recordings_attribute( $attributes ) {
    	$ariel_recording_details = get_field('ariel_recording_details');
    	if (!empty(get_field('ariel_recording_details'))) {
    
    	$attribute = array(
    		'name'         => 'Recording',
    		'value'        => $ariel_recording_details,
    		'is_visible'   => '1',
    		'is_taxonomy'  => '0',
    		'is_variation' => '0',
    		'position'     => '0',
    	);
    
    	$attributes['ariel_recording_details'] = $attribute;
    	}
    
    	return $attributes;
    }

    You can also add additional code to attributes.php to specify what order you’d like attributes to appear in…

  • The WYSIWYG and the oEmbed it uses is built into WP and would need to be addressed by WP I think, but not sure.

    Does the same thing happen if you add multiple Instagram oembed objects into a single WYSIWYG field?

  • Hi John:

    Thanks for getting back to me an sorry I didn’t have a chance to get back to you earlier. I was already using the code you linked to generate the excerpt at a custom word length, found this solution when researching this for another project a couple years ago (thanks for linking to this again, excellent solution).

    What I am still confused about is even when I set a more tag at a specific spot in the text (through the toolbar for the WYSIWYG field), the more tag doesn’t appear to be returned when getting the field contents in with get_field. I thought I might have made a template error in not checking for the more tag, however it doesn’t appear to be there at all. Is there something in the get_field function which is stripping out the more tag?

    No rush on this, please get back to me when you have a chance. Thanks again for your help!

  • You might want to check out this fork of one of my plugins https://github.com/puntonero/acf-input-counter. This person has added a limit on the wysywig field in ACF5. Not sure what version of ACF you are using and I can’t say that I’ve seen anything for ACF4 that will limit wysiwyg length.

  • If you use do_sortcode or you add the shortcode to the normal content area they are parsed the same. ACF 4 does not use the standard WP editor for its WYSIWYG fields, but it does it just calls do_shortcode, basically it just applies the same filters that WP does to the content in the standard editor. As far as I know there’s noting in ACF that would cause the standard WP gallery shortcode to function incorrectly.

    I just testing on a site using ACF 4, adding a gallery to both the standard WP editor and to an ACF WYSIWYG field. I added different images to each and reordered them in both. For both galleries the images appear I selected appeared in the order that I set them.

    The only thing that I can come up with is that you have something else on the site interfering with the operation of the WP gallery shortcode. What other plugins are you running? Try deactivating them. What theme are you using? It could be something in the theme.

  • Hi. We are using ACF 4.4.11 on WP 4.7.3. Now we do also use TinyMCE Advanced as our editor (have been for years), but it’s usually compatible with things.

    In Admin, we add galleries in standard WP fashion, using ‘Add Media’ button and media interface. I can’t see the actual shortcode in the WYSIWYG editor, as there is no ‘Visual/Text’ tab, but when I copy/paste it into the main content area and examine, the shortcode looks perfectly fine.

    As a test, I manually added the desired photo IDs to the ‘do_shortcode’ statement in the template file, and that did cause it to only show those specific photos. But it still didn’t follow the order properly. So there must be something unique in how the WP gallery shortcode is parsed in the standard content field.

  • I’m a little confused. What version of ACF are you using? Also, are you putting the standard gallery tag [gallery] in an ACF WYSIWYG editor or in some other way?

  • OK, thanks. Yeah, we prefer to stick with default WP functionality wherever possible (less dependencies or possible conflicts with updates), so was hoping something this basic would work OK.

    But I’m guessing we’re probably not going about displaying the gallery properly (I’m a def PHP novice). As we obviously can’t specify ID’s to include in the ‘echo do_shortcode’ statement, it’s appearing that it won’t by default respect what is done in the Admin editor (where it IS correct).

    When I add the same gallery code to the default post content field, the gallery DOES display as expected (only showing selected images, and in order specified). We were going to use that for other purposes, but maybe I can just re-arrange how and where things are added. The end-user would then just need to be on-top of the variables (e.g., large images, link to ‘none’, etc.).

    I’m sure there must be a way to get the same functionality from the ACF WYSIWYG field as from the default content field, just not sure how exactly to go about it…

  • Not really, You’ll need to create your own function that does everything that WP does.

    
    // add something like this to functions.php
    function fredy_custom_excerpt($text) {
      $text = strip_shortcodes( $text );
      $text = apply_filters('the_content', $text);
      $text = str_replace(']]>', ']]>', $text);
      $excerpt_length = apply_filters('excerpt_length', 55);
      $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
      return wp_trim_words( $text, $excerpt_length, $excerpt_more );
    }
    


    // when getting the field
    echo fredy_custom_excerpt(get_sub_field(‘wysiwyg_field_name’));

    the function was taken from here and changed as needed http://wordpress.stackexchange.com/questions/37618/apply-filters-and-the-excerpt-are-giving-unexpected-results

  • While you are using an ACF WYSIWYG you’re not using an ACF gallery field. Just a basic WP Gallery. From your description, it is working like it’s supposed to.

    To show only images that you want to show, or images that are attached to other posts you’ll need to use the “include” setting that is shown on the page you linked to. To do this you can click on the gallery edit icon to select images. The “menu_order” value specifies that the order should be the order you set them to by editing this gallery as well.

  • I figured out a better method which allows the field to be enlarged so it’s not a static height. This just removes the inline styling so I can set a height via CSS without the need for !important. Hope this helps someone else!

    
    // Remove ACF inline styles for WYSIWYG
    function my_acf_input_admin_footer() { ?>
    	<script type="text/javascript">
    		(function($) {
    			acf.add_action('wysiwyg_tinymce_init', function( ed, id, mceInit, $field ){
    				$(".acf-field .acf-editor-wrap iframe").removeAttr("style");
    			});
    		})(jQuery);	
    	</script>
    <?php }
    add_action('acf/input/admin_footer', 'my_acf_input_admin_footer');
    
  • I figured out a better method which allows the field to be enlarged so it’s not a static height. This just removes the inline styling so I can set a height via CSS without the need for !important. Hope this helps someone else!

    
    // Remove ACF inline styles for WYSIWYG
    function my_acf_input_admin_footer() { ?>
    	<script type="text/javascript">
    		(function($) {
    			acf.add_action('wysiwyg_tinymce_init', function( ed, id, mceInit, $field ){
    				$(".acf-field .acf-editor-wrap iframe").removeAttr("style");
    			});
    		})(jQuery);	
    	</script>
    <?php }
    add_action('acf/input/admin_footer', 'my_acf_input_admin_footer');
    
  • By the way, I just did something similar in this plugin https://github.com/Hube2/acf-options-page-adder. I added 2 wysiwyg fields to it. All of the settings in the the plugin are actually store in post_content of my post type, this speeds up loading because I don’t need to get the values of each field.

    You can see where the stored values are displayed in the function customize_end() on line 677 of the main file. I actually use get_post_meta() to retrieve the values so that part probably won’t help you, but if you want to look at that the function that gets the values and stores them in an array is on line 578 build_options_page_settings()

  • If you want to not process the shortcodes, or for that matter run any of ‘acf_the_content’ filters when getting the value from ACF

    
    get_sub_field('my_repeater_wysiwyg', false);
    // second parameter tells ACF not to format the value
    

    I just noticed that you are using the $post_id parameter in get_sub_field(). This function does not have a $post_id parameter, it uses the same ID given in the have_rows() call. Setting it to the post ID you are basically setting format to true.

    Anyway, if it’s not formatted you can store it that way and then do

    
    $content = apply_filters('acf_the_content', $value_from_your_stored_array);
    

    when you actually want to display the content that value holds

  • You’re running htmlentities on the value of the WYSIWYG field

    
    $my_repeater_arr['my_repeater_wysiwyg'] = htmlentities(get_sub_field('my_repeater_wysiwyg',$post_id));
    

    This is going to convert the quotes and <> brackets in the value you store.

Viewing 25 results - 526 through 550 (of 1,298 total)