Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • The field is not located on the same page where you are showing it. You need to supply the correct $post_id value.

    
    [acf field="field_name" post_id="123"]
    

    You are trying to get fields from a user.

  • In the case of the code provided you need to close PHP before the HTML portions and open PHP again after

    
    ?>
     <div class="member-meta">
        ........
     </div>
    <?php 
    
  • Just a quick note to say that I used the same code on a non-custom post type (the simple single.php that comes with Kadence theme) and I get the same error.

  • Hi John, sorry for the late reply as I just saw your email today.

    Now I have tried to make something with 2 plugins (JetEngine and Jet Smart Filters from CrocoBlocks) and they are nice, but still I need more features which aren’t available with this. Though by using then now I have more idea of CPT. Plus now I have a live example of my requirement to share with you. Please have a look.

    So our test website is: https://wordpress-490485-2085818.cloudwaysapps.com/
    – Aim is to built a website and then turn in into a Mobile app.

    Here please open AVAILABLE TAXI page : https://wordpress-490485-2085818.cloudwaysapps.com/page-1-available/

    You will see that there are entries which are being generated with a front end form (https://wordpress-490485-2085818.cloudwaysapps.com/available-taxi-form-submission/) which is also from jet engine (Jet Engine Form Builder).

    Plus on AVAILABLE page I have also added filters like:
    1. Taxi from:
    2. Taxi to:
    3. Car model:
    4th is just the remove option that appears when I choose any filter (good stuff)

    Now features which I can’t get from CrocoBlock is that I for the sake of getting minimum requirement need:

    A date filter (more important) I need a date filter, not date range, like if you see the AVAILABLE page (https://wordpress-490485-2085818.cloudwaysapps.com/page-1-available/) I have Date: in all entries. I want to filter these listing with DATE FIELD option.

    And

    A Multi Select Dropdown in form, example expedia.com, not as fancy as their but like when I search a city like Jaipur, then I just need to type J or JAI and I get related options in form.
    Its a important feature but I can live without it.

    Now date field option is available with JET Smart filter but its not working properly and the team at CrocoBlocks have accepted it as a Bug.

    So, I can get what I want with ACF?

    Regards
    Jatin Chhabra

  • Nice one!

    Re: creating/deleting posts as needed – each of my repeater rows require a file upload so I might use that attachment ID as a ‘key’ for each row to then create/update/delete posts as needed!

  • Please answer the question that I asked.
    I am attempting to help you figure out why it’s not showing. Your code does not indicate a reason. Debugging is required.

  • The simple answer is no.

    WordPress only returns a post as a result once in search results. What you want to do would require WP to return the same post multiple times in the results.

    In order to have them appear as different results they would need to be different posts instead of different rows of a repeater. If this is the results that you need then you should be using different posts instead of a repeater.

  • Key/Value store indeed has it’s own surprises. as I bump into php redis extension, the redis servers do provides store key-value and Redis shines when you want to use data structures such as lists, sets, strings, hashes, sorted sets with range queries, geospatial indexes, hyperloglogs, bitmaps, and streams

  • I would suggest building your sidebar as widget. WP recently integrated Gutenberg into the widgets aswel.

    To register a sidebar:

    if (function_exists('register_sidebar'))
    {
       // Define Sidebar Widget Area
       register_sidebar(array(
           'name' => __('Sidebar'),
           'description' => __('Sidebar voor de vervolgpagina\'s'),
           'id' => 'sidebar',
           'before_widget' => '<div id="%1$s" class="%2$s">',
           'after_widget' => '</div>',
           'before_title' => '<h3>',
           'after_title' => '</h3>'
       ));
    }

    Then implement this code in your sidebar area:
    <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar')) ?>

  • Hi there John!

    The loop is pretty much standard:

    
    if ( $posts ) {
        foreach ( $posts as $post ) :
            get_template_part( 'includes/loop-job', get_post_type());
        endforeach; 
        wp_reset_postdata();
    }
    

    Right? So at least I’m not missing something totally obvious. 😀 Thanks for that already! 🙂 I kinda hoped that there would be some kind of thing that everybody knew about except for me, but my code NOT being the obvious problem at least tells me I’m not a total idiot. 😉

    It might of course be some other plugin causing this problem.

    Now I could start and hunt down the culprit, but I just thought of a workaround that should do the trick as well, what do you think:

    The Problem is during sorting in a query and only hits the Address-Repeater section. I could of course hook into saving an article and THERE turn the cities into a string and save THAT in a normal (non-repeater)-field… Those aren’t affected by the glitch or whatever it is…

  • Old question, but I’ve never had an issue saving a script that in a text area field. I use them to allow this all the time. When I have had an issue with this it is usually to do another plugin, for example Wordfence, blocking it.

  • If your field is on an options page and not the current post then you need to supply the correct post ID

    
    [acf field="contact" post_id="options"]
    

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

  • ACF stores a list of user IDs as a serialized array.

    The meta key of the field will be "{$group_field_name}_{$sub_field_name}"

    your meta query might look something like this

    
    'meta_query' => array(
      array(
        'key' => "{$group_field_name}_{$sub_field_name}",
        'value => '"'.$user_id.'"',
        'compare' => 'LIKE'
      }
    )
    
  • I don’t have an exact answer for you, only a possible path to solving it.

    You will want to start here https://www.advancedcustomfields.com/resources/javascript-api/#filters-select2_ajax_data
    and here https://www.advancedcustomfields.com/resources/acf-fields-taxonomy-query/

    The first thing you’ll need to to is to alter the ajax data being sent for each field to include the values selected in the other field.

    Then in the query filters for each field you need to get the values sent in the ajax query and use that value in the ‘exclude’ argument for get_terms().

    Sorry that I cannot provide any code for you.

  • 
    $vid_args = array(
    	'posts_per_page'	=> -1,
    	'post_type'		=> 'resource',
    	'orderby' 		=> 'title', 
    	'order' 		=> 'ASC',
    	'meta_key'			=> 'sal_resource_type',
    	'meta_value'			=> '"Video"',
    	'meta_compare'		=> 'LIKE'
    );
    
  • to get unformatted value requires 3 arguments

    
    $images = get_field('slides', false, false); 
    
  • How are you looping over the posts returned by the query?

    To be honest, I don’t see any reason looking at the code you provided that the values would be shown other that then posts do not have any values set.

  • If you want these auto populated before the form is submitted then you need to create an AJAX request to get the values and populated the fields. I have an example of doing select fields here that would need to be modified to your needs https://github.com/Hube2/acf-dynamic-ajax-select-example/tree/master/dynamic-select-example

    A simpler solution would be

    1) Add an acf/prepare_field filter for the contract number and email fields. This filter would have to get the get the post type of the post being edited. If the post being edited is the proposal post type AND the field does not have a value THEN return false so the field does not need to be entered.

    2) Create an acf/save_post action, priority > 10. Here you get the ID of the value entered in the user relationship field, get the values from that user and update the other two fields with the correct values.

  • There is always the option of creating your own field type that has every option in it. There have been attempts to do this but they have all been short lived, meaning that after a time the authors stop maintaining them. But it the end it would not reduce the coding and could increase it. This question has been around and repeated for a long time. The main issue is that all the possibilities and use cases become a rabbit hole. To be honest, it would be impossible to encompass all of the options in my link group field into a single field.

    I have been building my system for some time, it does help to start on a new project. But it has evolved into a system that allows for the adding of CTA buttons to almost anything and there is a corresponding CTA button builder that allows clients to design CTA buttons and links. Yes, a template part could be seen as overkill for something as simple as a link, but it saves me a huge amount of time over re-codeing and I only have to make changes in a single location rather then hunt down all the places. I have not coded the showing of a link or CTA button in a very long time.

    ACF, while it can make things simpler, is a admin tool for building the admin UI. It’s goal is to make it easier and faster to build the UI for your client. ACF does not do anything that a developer cannot do without ACF using built in WP functions. Can you imagine the time it would take you to build a site if you had to build all of the UI parts that ACF lets you build, not to mention making it look as refined as an ACF field group. When Elliot built ACF the goal was to give us the tools to make the admin easier and free us from it so that we could devote our time to the front end of the site. I know that the linking seems like a PITA with all the different possibilities that you might need to incorporate.

    But all of this discussion does not fix the OP, that is of updating the urls in link fields. This is something that that is so complicated that even export/import tools to not replace hard coded URLs in content.

  • Thanks for your response @hube2 !

    In the acf/load_value filter, would I loop through all the users using a WP_User_Query? I’m not quite sure how I would check if the user has the old value selected to then replace with the new value.

    Do I need to rely on each user clicking update on the front end form for the changes (selection of the new value) to come into effect?

  • I don’t know if this will help you or make your dev process any easier. My goal when I build a site has to do with making things easy for the client and not necessarily making it easier for myself, so when I’m building the admin for the client I don’t even give much thought to how difficult it will be for me to code, I just make sure that it’s something that can be coded. However, I do my best to never code something more than once.

    I build in “modules” I have a field group that has all the settings I need for links, not only the ones you mention but others. I then clone this field group as the only sub field of a “Group Field”, this insures that all fields of my group are always “sub fields” With this in place I have a single template part file that is called to output links.

    
    // something like this goes into my template
    if (have_rows('group_field_name')) {
      // always true for a group field that exists
      while (have_rows('group_field_name')) {
        // always executes once for group fields that exist
        get_template_part('template-parts/components/link);
      }
    }
    

    So I have only coded this once. My group has become quite complicated, but if changes are made I only need to make them in a single file.

    The field group for links can also be cloned as the only sub field in a repeater and the template part file will still work but allow the client to add multiple CTA buttons.

    I actually use a true/false field the new window setting. The label on the true false field is
    – Same Window = false
    – New Window = true
    and the code in my template part for building this part of the link button is

     
    $target = '';
    if (get_sub_field('target')) {
      $target = ' target="_blank"';
    }
    

    and example of my link output

    
    <a href="<?php echo $url; ?>" class="<?php echo implode(' ', $cta_classes) ?>"<?php echo $title.$rel.$target.$onclick; ?>><?php echo $text; ?></a>
    

    Also, when it comes to a URL and the client entering a URL, I do not use a URL field because it is too limiting. For example lets say that you want to allow the client to enter anything other than a URL. My clients and the people I work with want to be able to enter anchor links as well as tel:, mailto:, sms: and ftp: links. So instead of using a URL field I use a text field with custom validation. Building separate fields would increase the code and complicate things for the client. Instead I have a text field that will accept anything that appears to be a valid href value and as part of the client’s instruction when handing over the site they are shown how to use this field and the field has very good instructions to help remind them.

    
    add_filter('acf/validate_value/key=field_XXXXXXXX', 'validate_text_as_href', 20, 4);
    function validate_text_as_href($valid, $value, $field, $input) {
      // this allows links starting with
      // / (site root relative), http://, https://, ftp://, # (anchor), mailto:, tel:, sms:
      if (!$valid) {
        return $valid;
      }
      if (!empty($value)) {
        if (!preg_match('%^(https?\://|ftp\://|/|#|mailto\:|sms\:|tel\:)%', $value)) {
          $valid = 'Enter a Valid HREF Value';
        }
      }
      return $valid;
    }
    

    As to automatically updating or redirection, I have not built anything that will automatically redirect if the slug of a page is changed. I will need to look into that, what I do know is that what is built into WP rarely works as expected.

    As far as automatically updating links when a slug or url changes, you would need to keep some type of history on the slug/url of the page when it is updated. You would need to add a pre_post_update action that somehow checks to see if the url of the page is being changed. If it is then you’d have to figure out how to lookup and changed all of the other posts and pages where there is a link to the page being updated and change them without this process timing out the admin page refresh. This would basically mean that you’d have to record somewhere/somehow all of the places where a link to the page is saved to allow a quicker lookup so that they can be found quickly and updated.

    This brings me back to the automatic redirection because the testing to see if the URL has changed for a page sparked an idea. You could as in the above add a pre_post_update action and if possible record a history of all of the URLs that were ever assigned to this post and then on a 404 you could do a search for posts that have had the missing URL. This isn’t actually a bad idea that I may look into.

  • You did not really answer my question about more detail.

    What I am assuming is that

    1. You load data into a field that can be selected
    2. Based on this selection you add choices to a second field or multiple other fields for selection
    3. Repeat if additional fields are dependent on the selection of the first field

    I have some examples of doing this here https://github.com/Hube2/acf-dynamic-ajax-select-example

    Basically what you are looking at is building a JavaScript/AJAX application that does the requests and population of choices in addition to adding PHP that loads the initial choices of the first field.

    What I would do is that I would create a cusome post type to hold posts returned by the API and then I’d probably use a post object field to allow the user to select on of those posts rather than try to store all of this information in fields.

Viewing 25 results - 5,401 through 5,425 (of 21,337 total)