Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Hi @almer1984

    It is possible to query more than one custom field by first allowing for multiple $_GET variables in your pre_get_posts filter. To do this, simply copy and paste your onderwerp code and change the field_name.

    You will need to change quite a bit of your JS to allow for multiple values to be added to the URL. I would advise that you write a function that returns the URL based on all the selected checkbox values.

    You can then attach another ‘click’ event to the second checkbox inputs and use this function to redirect the URL.

    I would just like to point out that this PHP and JS logic is quite advanced, and I won’t be able to help much on this free ACF support forum. If the task seems too complicated, perhaps try breaking it up into steps and research these independently.

    Hope that helps.

    Thanks
    E

  • I was looking for the same thing and tried the example above, was the good way but no so simple for me, finally it done this :
    1 : create the checkbox field with the different size
    (thumbnail : thumbnail
    medium : medium
    large : large
    full : full
    custom-size : custom-size)
    2 : the code to display

    <?php 
    $attachment_id = get_field('image');
    $field = get_field_object('size');
    $value = get_field('size');
    $label = $field['choices'][ $value ];
     
    $image = wp_get_attachment_image_src( $attachment_id, $label );
    // url = $image[0];
    // width = $image[1];
    // height = $image[2];
    ?>
    
    <a href="<?php echo $image[0]; ?>" class="fancybox"><img src="<?php echo $image[0]; ?>" /></a>

    It works good and the check box very easy to use !
    Now have to find a solution to the Gallery field…

    We really need this feature, without all the pictures are full size !! it looks a detail but when you have a lot of pictures to manage you understand how important it is. Many Thanks ! ACF is great !

  • Hi @thesrpr

    I just noticed that your code is completely overriding the $args.
    This is why the WP_Query is breaking. Please modify the $args, not override them.

    You can do this like so:

    
    $args['posts_per_page'] = 200;
     
    return $args;
    
  • Hi @Sintel

    Sorry, I do not understand your question. Can you please clearly describe your question in an easy to understand manor.

    Thanks
    E

  • Hi @sixfootjames

    To respond to your original question, to query a value which is saved as an array, you will need to perform a LIKE compare. You can read about this here:
    http://www.advancedcustomfields.com/resources/field-types/checkbox/

    For a good understanding of how to create a front end search engine, try this:
    http://www.advancedcustomfields.com/resources/tutorials/creating-wp-archive-custom-field-filter/

    Thanks
    E

  • Hi all, here is an update.

    I am using a text input field to add a shortcode. My shortcode looks like this:

    [fancygallery id="1" album="6"]

    in my php page, I am doing this:

    <?php
    	$myvalue = get_field( "cf_custom_gallery" ); 
    
    	
        echo do_shortcode("$myvalue");
    ?>

    but it is not outputting. If I manually do this:

    <?php
    	
        echo do_shortcode('[fancygallery id="1" album="6"]');
    ?>

    it works.

    ANy suggestions ?

    Thanks,

    JC

  • FYI – The Tri.be support forum found a resolution for issue with a snippet to de-register the acf-datepicker that, according to them, is conflicting with the use of standard jquery-ui-datepicker. From https://tri.be/support/forums/topic/plugin-conlict-js-errors-from-tec-front-end-acf-form-on-an-event-template/ :

    What is happening is that ACF is using it’s own custom datepicker, enqueued with “acf-datepicker”. The thing is, it conflicts with WP’s ’jquery-ui-datepicker’, which is basically the same thing only it is provided by WordPress. Our plugin uses ’jquery-ui-datepicker’ to avoid conflicts just like this. Other plugins need to be using the scripts that WordPress provides, as this limits conflicts and optimizes the site loading times. Unfortunately ACF is not doing this.

  • Hi Elliot,

    I’ve been having a look and don’t know if I’ve got something wrong with it but can’t access the global $current_screen, get_current_screen() returns null and the $_GET array is empty when I run them from within the filter. The $post term passed to the filter is also null.

    I’m going round in circles a bit here.

    function mo_acf_available_posts( $args, $field, $post )
    {
    	global $wp_query;
    	global $page_now;
    	$term = '1'; // WORK OUT HOW TO GET ACTIVE TERM
        $args['client'] = $term;
    	var_dump($args);
    	echo "<hr>";
    	var_dump($field);
    	echo "<hr>";
    	var_dump($wp_query);
    	echo "<hr>";
    	var_dump($page_now);
    	echo "<hr>";
    	var_dump($_GET);
    	echo "<hr>";
        return $args;
    }
    //add_filter('acf/fields/post_object/query/name=excluded_projects', 'mo_acf_available_posts', 10, 3);

    This filters the posts by the client term id=1, I just need to get the current term ID and exchange the hard-coded 1 in.

    Here’s the vars dumped by the server for each:

    $args:
    array(7) { ["numberposts"]=> int(-1) ["post_type"]=> string(7) "project" ["orderby"]=> string(5) "title" ["order"]=> string(3) "ASC" ["post_status"]=> array(5) { [0]=> string(7) "publish" [1]=> string(7) "private" [2]=> string(5) "draft" [3]=> string(7) "inherit" [4]=> string(6) "future" } ["suppress_filters"]=> bool(false) ["client"]=> string(1) "1" }

    $field:
    array(18) { ["key"]=> string(19) "field_52f3bb5c778f0" ["label"]=> string(17) "Excluded Projects" ["name"]=> string(27) "fields[field_52f3bb5c778f0]" ["_name"]=> string(17) "excluded_projects" ["type"]=> string(6) "select" ["order_no"]=> int(1) ["instructions"]=> string(0) "" ["required"]=> int(1) ["id"]=> string(27) "acf-field-excluded_projects" ["class"]=> string(11) "post_object" ["conditional_logic"]=> array(3) { ["status"]=> int(1) ["rules"]=> array(1) { [0]=> array(3) { ["field"]=> string(19) "field_52f3b64ed5d5c" ["operator"]=> string(2) "==" ["value"]=> string(1) "1" } } ["allorany"]=> string(3) "all" } ["post_type"]=> array(1) { [0]=> string(7) "project" } ["taxonomy"]=> array(1) { [0]=> string(3) "all" } ["allow_null"]=> int(0) ["multiple"]=> int(1) ["field_group"]=> int(149) ["value"]=> string(0) "" ["choices"]=> array(0) { } }

    $wp_query:
    object(WP_Query)#158 (51) { ["query"]=> NULL ["query_vars"]=> array(0) { } ["tax_query"]=> NULL ["meta_query"]=> bool(false) ["date_query"]=> bool(false) ["queried_object"]=> NULL ["queried_object_id"]=> NULL ["request"]=> NULL ["posts"]=> NULL ["post_count"]=> int(0) ["current_post"]=> int(-1) ["in_the_loop"]=> bool(false) ["post"]=> NULL ["comments"]=> NULL ["comment_count"]=> int(0) ["current_comment"]=> int(-1) ["comment"]=> NULL ["found_posts"]=> int(0) ["max_num_pages"]=> int(0) ["max_num_comment_pages"]=> int(0) ["is_single"]=> bool(false) ["is_preview"]=> bool(false) ["is_page"]=> bool(false) ["is_archive"]=> bool(false) ["is_date"]=> bool(false) ["is_year"]=> bool(false) ["is_month"]=> bool(false) ["is_day"]=> bool(false) ["is_time"]=> bool(false) ["is_author"]=> bool(false) ["is_category"]=> bool(false) ["is_tag"]=> bool(false) ["is_tax"]=> bool(false) ["is_search"]=> bool(false) ["is_feed"]=> bool(false) ["is_comment_feed"]=> bool(false) ["is_trackback"]=> bool(false) ["is_home"]=> bool(false) ["is_404"]=> bool(false) ["is_comments_popup"]=> bool(false) ["is_paged"]=> bool(false) ["is_admin"]=> bool(false) ["is_attachment"]=> bool(false) ["is_singular"]=> bool(false) ["is_robots"]=> bool(false) ["is_posts_page"]=> bool(false) ["is_post_type_archive"]=> bool(false) ["query_vars_hash"]=> bool(false) ["query_vars_changed"]=> bool(true) ["thumbnails_cached"]=> bool(false) ["stopwords":"WP_Query":private]=> NULL }
    This doesn’t look right, lots of false values and no information, think this might be why I can’t get the $_GET var.

    $pagenow:
    NULL

    $_GET:
    array(0) { }

    I may well be doing something stupid here but thought I’d post up the code in case someone else can see what I need to do, any advice would be great. Thanks,
    Danny

  • Hi @Till

    Thanks for the bug report. The line in question is modifying the WP media object.
    I haven’t seen this error before, so I will assume for now that it is server specific.

    Are you able to setup a local environment to test a blank WP install with ACF?

    Thanks
    E

  • I guess what I’m asking is where in your plugin is the HTML I can see when looking at my post page with my text field on created.

    I’d like to add:
    onblur="myFunction()"

    to this HTML created by ACF
    <input type="text" id="acf-field-miles" class="text" name="fields[field_52f526e67d916]" value="8000" placeholder="e.g 10,000" testing="">

    Is it line 79 in text.php?

    I can’t seem to work out where exactly that is created. Sorry 🙁

  • Ok thanks.

    I just meant an onblur event , opposite of onfocus. So when the user tabs out of a field. Not an actual blur effect.

    The conversion and coding are quite straight forward, I’m just no clear where I’d put the code as it’s being created by ACF.

    Here’s a version of what I mean. Fill in the miles tab to the Kilometres and it auto fills.

    Would you be able to suggest where or what I might target using the ACF plugin?

    Thanks again.

  • Hi @Will

    If $internals is an array of posts, then the get_sub_field function is working correctly. Perhaps the issue lies in the setup_postdata funciton which can cause many problems wiht the global $post object.

    Try this instead:

    
    $internals = get_sub_field('internal_link');
    foreach($internals as $p): ?>
    <a href="<?php echo get_permalink( $p->ID ); ?>">
    
  • Hi @sja

    ACF does not offer this kind of functionality, however, you can easily add some custom jQuery to the page.

    jQuery can be used to add events to elements such as blur.

    Further questions regarding this matter would be best asked on a stackoverflow forum, as many web developers are actively posting code and solutions for jQuery.

    Thanks
    E

  • Hi @pastore1980

    You can perform a meta_query on a ‘multi-value’ field by using a LIKE parameter.
    Here is an example (last example on page):
    http://www.advancedcustomfields.com/resources/field-types/checkbox/

    Thanks
    E

  • [quick update post-debug]

    this is my array before $field

    Array
    (
        [choices] => Array
            (
                [home] => Homepage
                [servizi] => Servizi
            )
    
    )

    (Results are correct)

  • @elliot I did. Whether I use 50 or 200 doesn’t matter. If I leave the function out (which means it is querying six thousand posts) it works just fine but anything I do to try to reduce that numbers breaks it

  • Hi, thank you for your support.
    For your questions:
    1) yes
    2) yes
    3) yes

    However, this code works!

    <?php
    $zone_articoli = get_field('zona_per_i_pacchetti');
    $args = array(
      'post_type'=>'pacchetto',
      'meta_key'=>'zona_per_gli_articoli',
      'meta_value'=>$zone_articoli
    );
    $loop = new WP_Query($args);
    while ( $loop->have_posts() ) : $loop->the_post(); ?>
    
    <div> 
    <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    </div>
                        <?php endwhile; wp_reset_postdata();?>

    A last question:
    If i want use a multiple select for a field, how i can do it?
    The field that i want use is ‘zona_per_gli_articoli’
    Thank you so much for your help!

  • Hi @andisaleh and @elliot

    I feel this is getting closer but still can’t work out why such a simple task of grabbing one value from another post and matching it to current post is so hard. I am going crazy! haha.

    New query is now this, but unfortunately it returns nothing.

    <?php
    $args = array(
      'numberposts'=> -1,           // Fetch all posts...
      'post_type'=> 'release',      // from the 'release' CPT...
      'meta_key' => 'artist_name', // which inside this meta key...
      'meta_value' => get_the_ID(),   // has this meta value.
    );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) :
      echo '<ul>';
      while ($my_query->have_posts()) : $my_query->the_post();
    ?>
    <li>
    <img src="<?php the_field('cover_image'); ?>" />
    <?php the_field('artist_name'); ?>
    <?php the_title(); ?>
    </li>
    
    <?php 
    endwhile; echo '</ul>';
    endif; wp_reset_query(); ?>

    Failing this – do either of you know any quick places I can go to pay someone to do this? I just don’t have any contacts in that regard.

  • Hi @andisaleh

    The meta_value should be the value which is saved, which in this case is the ID, not the title.

    So, you should change the_title() to get_the_ID()

    This will then query posts of post_type release where the selected artist is the current artist being viewed.

    Thanks
    E

  • Hi @andisaleh

    Thanks for the explanation, but that now outputs ALL of the releases. Which makes it no different to my original post/query which outputs everything.

    How do I get it to recognize what artist page i am on and then ONLY output releases from that artists. Right now it is just bringing in every release from every artist on every page.

    Does that make sense?

  • I totally understand that.nothing worse than cutting a feature many people use. but i only ask myself one question. what image size is wordpress actually using if you select e.g. thumbnail even if it is unset in the functions.php. e.g. the preview size was set by default to thumbnail on my side and the image size used looked much much bigger than the thumbnail size i would have expected. i just rechecked it. if you set the preview size to thumbnail and it is unset acf and wordpress use the full size instead. same procedure if you use medium or large. always the full version is used instead of the unset one.

  • Here’s a step-by-step.
    1. Find a way to get the artist’s name. It’s stored as the post’s title. Great. We can grab it with the_title().
    2. Find where the artist is declared in the ‘release’ CPT. It’s inside a custom field named album_artist. Custom fields are stored inside meta keys.
    3. Construct a query with these values and spit out the results. You get:

    <?php
    $args = array(
      'numberposts'=> -1,           // Fetch all posts...
      'post_type'=> 'release',      // from the 'release' CPT...
      'meta_key' => 'album_artist', // which inside this meta key...
      'meta_value' => the_title()   // has this meta value.
    );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) :
      echo '<ul>';
      while ($my_query->have_posts()) : $my_query->the_post();
    ?>
    
    <li><?php the_field('album_title') ?></li>
    
    <?php 
    endwhile; echo '</ul>';
    endif; wp_reset_query(); ?>

    Hope that helped.

  • Hi @pastore1980

    To clarify:
    1. The above code is used int he single.php template (view for a post)
    2. The filter value is loaded via $zone_articoli = get_field('zona_per_i_pacchetti');
    3. The $loop find all pacchetto and ignores the filter

    Perhaps you need to debug your code. Try removing the $zone_articoli from the equation and hard code the meta_query.

    Also, is the select field a single or multi select?

    Thanks
    E

  • Hi @megancm

    Your last reply is quite vague. Which array are you talking about?

    The above code was to help you see visually that the loop is working correctly.
    The array variable printed out is the selected relationship items/ Yes, these should be different, shouldn’t they?

    Please look at the outputted data and determine if the data is correct, or if it is not.

    Thanks
    E

Viewing 25 results - 18,776 through 18,800 (of 21,345 total)