Support

Account

Home Forums Search Search Results for 'Wysiwyg'

Search Results for 'Wysiwyg'

topic

  • Helping

    How to fix e.sorted[f].split is not a function when use Wysiwyg Editor

    Hi, I have used acf for a custom tempalte page using classic editor, but an error occurs when I use Wysiwyg Editor, Please give me a solution. Thank for all

  • Solved

    Wysiwyg Editor – hooks for "Add Media" button?

    I have a Wysiwyg Editor field, with media upload button enabled, and I would like to identify and target the AJAX queries coming from its media upload button (“Add Media”). Specifically, I’d like to 1) filter the shown attachments in the modal and 2) operate on the uploaded attachment.

    I have done something similar with Image upload fields, by following this solution: https://support.advancedcustomfields.com/forums/topic/filter-gallery-items/#post-41465

    Thus, for an Image field, I set up a filter for ajax_query_attachments_args and checked against the _acfuploader identifier with an if ($_POST['query']['_acfuploader'] == $THE_FIELD_ID) condition. Inside that condition I could then modify the AJAX query e.g. to show only attachments uploaded by the current user.

    Then, after submitting the form (for my very own use case it was appropriate to use the woocommerce_save_account_details hook), I simply got the attachment’s ID from the $_POST data using $_POST['acf'][$image_field_key] and could then modify that attachment.

    
    // (1) filter the shown attachments
    function restrict_current_user_to_own_attachments( $query = array() ) {
    
        // Allow requests only from users with access
        if ( ! current_user_can( 'upload_files' ) ) {
            wp_send_json_error();
        }
    
        // Only target the specific ACF field
        if ( $_POST['query']['_acfuploader'] == $THE_FIELD_ID ) {
    
            $user_id = get_current_user_id();
    
            if ( $user_id ) {
                // Query only attachments uploaded by the current user
                $query['author'] = $user_id;
            }
        }
        else if ( $_POST['action'] == 'query-attachments' && !current_user_can( 'administrator' ) ) {
    
            $user_id = get_current_user_id();
    
            if ( $user_id ) {
                $query['author'] = $user_id;
            }
    
        }
        else if ( $_POST['action'] == 'query-attachments' && current_user_can( 'administrator' ) ) {
    
            $user_id = get_current_user_id();
    
            // I could target a specific page, if I was unable to target the field.
            if ( strpos( $_SERVER[ 'HTTP_REFERER' ], "/${$MY_PAGE}" ) !== false && $user_id ) {
                //  manipulate AJAX query
            }
    
        }
    
        return $query;
    }
    // Filter wp uploader shown attachments using ajax_query_attachments_args
    add_filter( 'ajax_query_attachments_args', 'restrict_current_user_to_own_attachments', 10, 1 );
    
    // (2) operate on uploaded attachment
    function my_save_form( $user_id ) {
        if ( isset( $_POST['acf'][$THE_FIELD_ID] ) ) {
            // ...
            if ( is_user_logged_in() && current_user_can('upload_files') ) {
                $attachment_id = (int) $_POST['acf'][$THE_FIELD_ID];
                // Do stuff to the attachment
            }
        }
    }
    add_action( 'woocommerce_save_account_details', 'my_save_form', 10, 1 );

    The problem with the Wysiwyg Editor’s media upload button is that I couldn’t find anything identifiable about it, in order to be able to modify the AJAX query for that purpose. So I made a compromise and modified it for ordinary user roles and for more elevated users such as admins (current_user_can( 'administrator' )) I targeted the entire page instead of the field, using the $_SERVER['HTTP_REFERER'] (admins are trusted to not spoof the referer).

    However, I still need to operate on the attachments that were uploaded from that specific “Add Media” button, right after they were uploaded, and I’ve failed to find any hook where I could have both access to the attachment ID AND where the $_SERVER['HTTP_REFERER'] would point to the page of the ACF form. If anyone knows of any useful hook, it’d certainly save me plenty of more hours of trying.

  • Unread

    Wysiwyg Editor

    Wysiwyg Editor
    More function how to change

  • Solved

    Wysiwyg Editor

    Wysiwyg Editor
    More function how to change

  • Solved

    Wanting to load a specific Flexible Content field for new posts?

    I have been looking everywhere on options to load specific fields for new posts – eg using Flexible Content fields for blog posts, when the user creates a New Post, there are not fields shown.. and new users are not sure what to start with. So, I want to load the WYSIWYG editor layout when they create a New Post.

    Here is how to do that:

    
    // flexible_content below, is the name of the Flexible Content field
    add_filter('acf/load_value/name=flexible_content', 'add_fields', 10, 3); 
      function  add_fields($value, $post_id, $field) {
        if ($value !== NULL) {  // $value will only be empty for New Posts
          return $value;
        }
        // lead layouts
        $value = array(
          array(
            'acf_fc_layout' => 'heading'
          ),
          array(
            'acf_fc_layout' => 'wysiwyg_editor' // wysiwyg_editor is the name of the layout
          )
        );
        return $value;
      }
    
  • Solved

    Get sub field object of field in a group?

    I have a wysiwyg field in one of my flexible content blocks, and I call “wysiwyg” as a class for the block with the following code:

    
    <?php
    $content = get_sub_field('text');
    
    $field = get_sub_field_object('text');
    $fieldtype = $field['type']; ?>
    
    <div class="<?php echo $fieldtype; ?>">
    

    It works great, but I need to achieve the same thing with a wysiwyg field within an acf field group and I can’t get it to work the same way. This is what I have now:

    
    <?php
    
    $content = get_sub_field('twi_fields');
    $text = $content['twi_text'];
    
    $field = get_sub_field_object('$text');
    $fieldtype = $field['type']; 
    ?>
    
    <div class="<?php echo $fieldtype; ?>">
    
  • Helping

    ACF Removing Editor of other Plugin

    Hello,

    I have come into an issue where whenever I install and activate ACF, it is conflicting with another plugin called Eventin by Themewinter. The issue is that the WYSIWYG editor gets removed from the event custom post type created by Eventin.

    Has anyone come across similar problems? And is there a way to resolve this?

  • Solving

    Add Class to Paragraphs in WYSIYWG Field

    I have a custom field that includes a basic WYSIWYG editor. When I call this field, on the frontend, it shows paragraph tags, but I would like to be able to dynamically add a class to all of these paragraphs for styling purposes. I would even be fine with just adding a class to anything in the editor, regardless if paragraph or not. The main issue is that I can only add classes to the field itself, and I cannot add classes to what a client would write within the editor.

  • Solved

    Post object as ACF – shortcode problem

    Hello,

    I use two custom post types: eventtype and event. The eventtype has a wysiwyg field that may contain any kind of shortcodes. I added the eventtype to the event as a custom field (post object). If I check only the eventtype content, it’s all good, but when I processing events, and I print eventtype content, the shortcodes inside the eventtype content doesn’t show.

    $fields = get_fields(get_the_ID()); // get event custom fields
    if ($fields):
      $event_type = get_field('eventtype'); // get event type custom field 
      if ($event_type): 
        echo ($event_type->post_content);
      endif;
    endif;

    Can you help me with this?

  • Unread

    Troubleshooting steps for field that won't update

    We’re seeing an issue where a field won’t save to the database. We add content, click “Update” and see a confirmation that the page was updated, but if you refresh the page editor, the content added is gone.

    Looks to me that the data is not writing to the database..

    This is a WYSIWYG field in a group that is applied to a custom post type.

    Could you suggest troubleshooting steps to follow?

    Here is what I’ve tried:

    • Duplicating the field group
    • Trying to log data to console – nothing coming through
  • Solved

    Text is displayed in one block

    Hi,

    I have a custom field that I have created that is a Wysiwyg Editor field. When I enter several paragraphs of text within this field on the page I want this to be displayed it seems to ignore any HTML and just displays one block of text on the website front-end. The code I am using is shown below.

    Can anyone tell me why the HTML formatting isn’t showing please?

    <?php $content_middle = get_post_meta( get_the_ID(), 'content_middle', true); ?>
    `<?php echo $content_middle ?>

  • Solving

    Generate post title from two ACF fields

    This is probably so simple for you all…

    I have a custom post type called Job Updates (slug is job_updates)

    It has 3 fields…

    Job – a taxonomy
    Date – date picker
    Update – WYSIWYG

    I would like the title of the post to auto generate based on the Job + Date
    So if the job is Sherman Water Damage, it would be Sherman Water Damage 6-1-2022

    I’ve searched the forum and tried several different functions in the Snippets app, while swapping out their variables for mine, but none seem to work. I don’t know php, so that might be part of it.

  • Solved

    Using Shortcode in WP Editor for Woo Product

    Hi, I’m not sure whether this is possible and if not please tell otherwise.

    I’ve set up a Link type field in my group for post type. I’m trying to display this link in a HTML href attribute inside the wysiwyg editor when editing Woocommerce Products.

    For example, the link is to view the product on another website. So in the field when editing the product I’ve inserted the full URL. In the editor, I’ve tried to insert ACF Shortcode.

    <p><a target="_blank" rel="nofollow noopener" title="View Products Details on XYZ">Click Here</a></p> to alternatively view this product Somewhere Else.</p>

    This is an example. I want to display the ‘Click Here’ link in various parts of the editor, so it makes to use a custom field.

    Considering there is no output, I presume I’m doing it wrong?

    Any feedback would be great.

    Thanks,

  • Solving

    Conflict with ARVE plugin

    Seems to be a conflict with ARVE video embed plugin. I’m also using Classic Editor, but when ACF pro is active – the ARVE popup is obscured by the wysiwyg toolbar. I tried testing with all my other plugins and only happens when ACF is active.
    WP core version 5.9.3, all plugins updated.

  • Solving

    Clone Field Bugs

    There are 2 bugs I’m encountering with clone field type. Here is a run down of my setup:

    • I use Flexible Content repeater fields to add building blocks. One of them is called Content, for simple content needs, which supports content types such as (none, WYSIWYG, etc.)
    • I use field groups to manage fields of each building block, so there is a field group for Content, which has fields for content types, WYSIWYG, etc.
    • I use field groups to manage fields of components used in building blocks. One of those is Content. This is different from the building block above because this is content in its simplest form. The building block above may have additional fields.

    So a hierarchy of my blocks-to-components look something like this:

    1. Content (block field group)

      1. Header (component field group)

        1. Header Content Type (radio field)
        2. Header Content (wysiwyg field, shows if Header Content Type = “content”)
        3. Header Code (textarea field, shows if Header Content Type = “code”)
      2. Footer (component field group)

        1. Footer Content Type (radio field)
        2. Footer Content (wysiwyg field, shows if Footer Content Type = “content”)
        3. Footer Code (textarea field, shows if Footer Content Type = “code”)
      3. Background Settings (component field group)
        1. Background Type (radio field)
        2. Background Color (color field, shows if Background Type = “color”)
        3. Background Image (image field, shows if Background Type = “image”)
    2. Slider (block field group)

      1. Slides (repeater field)
        1. Content (component field group)
          1. Content Type (radio field)
          2. Content (wysiwyg field, shows if Content Type = “content”)
          3. Code (textarea field, shows if Content Type = “code”)
      2. Slider Settings (component field group)
        1. Autoplay (true/false field)
        2. Loop (true/false field)

    …totaling 5 field groups, 3 for reusability:

    1. Blocks
    2. Content: block part of building block list in #1
    3. Content: any block that needs content fields
    4. Background Settings: any block that needs background settings
    5. Slider Settings: any block that needs slider settings

    Bug 1

    When more than one field group shares the same name, the second field group’s name is not displayed in the clone field dropdown list of options. For example, when I add a clone field to other blocks to clone and use Content (#3), I see the field group name for #2 in the list, not #3. Though I do see the fields for #3 in the list.

    Bug 2

    When the same field group is present more than once as a clone field, despite using prefixed labels and field names, there does not seem to be any isolation with the conditional displays. They seem to be affected by the first instance instead. For example, using my setup example above, the conditional display for Footer Content and Footer Code is affected when Header Content Type is changed instead of Footer Content Type.

  • Unread

    No links inside paragraphs – wysiwyg editor

    Hello, I used ACF on the website I recently created. I wanted to make a customizable paragraph with links inside, so I made a WYSIWYG editor field. No matter what I do, if the dynamic content is inside the <p> tag, it ignores all links and pastes them as simple text. It works without <p> tags without any problems, but I want to keep the paragraph tags as I feel it would affect SEO in the future.

    Code I used to paste content:
    <?php the_field("opis_wydawnictwa_1", 99, false, false); ?>

    True, true parameter creates the <p> tag but ignores links. If I add <p> tags myself in HTML it creates the same issue.

    Is there any way to keep <p> tags and make all links work?

  • Solving

    Add custom drop-down menu with custom styles to wysiwyg editor

    To the ACF wysiwyg field, I would like to add a custom drop-down menu from which you can select certain pre-defined styles. Is there a way to add such a button to the tinymce editor?

    I thought I might build on the code snippet here: https://www.advancedcustomfields.com/resources/customize-the-wysiwyg-toolbars/
    But adding that code doesn’t seem to do anything to my wysiwyg field…

  • Solving

    ACF wysiwyg images not responsive

    Not quite sure how this happens, but I see many sites with acf wysiwyg fields and they have images insterted into.
    If user chooses other image size than the default(full) then it seems that wp will insert html code into img tag size=”1024″ or something that no css-rules can ovwerwrite. And this breaks the mobile views.

    How should this be prevented ?

  • Helping

    Need to remove tag from one of two wysiwyg fields

    I have a Repeater field (name “content_repetar”) which is located under options.

    There are two wysiwyg fields under this repeater field, name as below:

    content_1
    content_2

    The wysiwyg field is generating <p> tags automatically. But I want to remove the <p> tag from the filed “content_1” but keep <p> tag for the filed “content_1” and other wysiwyg fields.

    How can I do that?

  • Helping

    Best practice for taxonomy description field

    I see that taxonomies have a default description field with comment:

    The description is not prominent by default; however, some themes may show it.

    I have added my own detailed description WYSIWYG field but I was wondering what best practices are for using the default description field? I feel that I should put something in that field since it is available.

  • Unread

    Using Flexible Content but should it be InnerBlocks?

    I’m using ACF Gutenberg Blocks. I have my block fields, but within that I also want to be able to use “Blocks”, but not the main blocks if that makes sense.

    So like primary and sub blocks. As of now I’m using a Flexible Content field for the sub blocks. Which are used to essentially replace WYSIWYG and shortcodes with things like Header, Button, Image Grid, whatever the content dictates.

    My question is how to I do this in a better way maybe? Is it InnerBlocks? If yes, where are some better code examples to follow?

    Here are photos to describe what I’m talking about. Thanks everyone!!

    Admin Preview

    Frontend Preview

  • Solving

    ACF Accordion field

    Hi all

    I was excited to see an accordion field in ACF pro but i can’t get it to work.

    I have set up a field with an ‘Accordion’ type and then a content WYSIWYG field underneath which according to the the docs with attach it to this panel until another is defined.

    I have repeated this twice for two panels.

    I can’t however, find any documentation on how to actually implement this. It says it will generate collapsible panels with the label as the title but it does not.

    Any help on the actual code for this would be greatly appreciated

    My accordion panels are just called Panel and panel two with the text content being accordion_text_1 and accordion_text_2

    I would usually start with code in the support forum but I don’t actually know where to start. At the moment, I have simply called the two WYSIWYG content fields

    Thanks
    Sheree

  • Solving

    Update to WP 5.9.1 breaks media selection

    Hi there,

    the latest update to WordPress 5.9.1 breaks all media upload prompts connected to ACF fields. Simple file uploader or the option within a wysiwyg editor field tries to open up the media library/upload window but it isn’t displayed correctly.

    Is this a common issue or just within our theme?

    Thanks!

  • Helping

    WYSIWYG editor is broken, wont save values ( tabs,toolbar,

    I have created a repeater field that contains a WYSIWYG field. I cannot save any values for Tabs, Toolbar, or Show Media Upload Buttons. Each time I try to save them, they default back to default values.. It doenst matter if WYSIWYG is within repeater or not, doesn’t work

    I have tried saving as JSON, download, editing, reupload.. didn’t work

    I have deleted and remade the fields, didn’t work

    I have deleted and remade the whole field group, didn’t work

    I disabled every other plugin on site, didn’t work

    I just downloaded and installed ACF pro, how could this be so terribly broken out of the box?

  • Solving

    WYSIWYG editor is broken within repeater field, wont save values ( tabs,toolbar,

    I have created a repeater field that contains a WYSIWYG field. I cannot save any values for Tabs, Toolbar, or Show Media Upload Buttons. Each time I try to save them, they default back to default values.. It doenst matter if WYSIWYG is within repeater or not, doesn’t work

    I have tried saving as JSON, download, editing, reupload.. didn’t work

    I have deleted and remade the fields, didn’t work

    I have deleted and remade the whole field group, didn’t work

    I disabled every other plugin on site, didn’t work

    I just downloaded and installed ACF pro, how could this be so terribly broken out of the box?

Viewing 25 results - 76 through 100 (of 1,297 total)