Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • You might consider parent and child post types (see http://justintadlock.com/archives/2013/10/07/post-relationships-parent-to-child for a bit about this). You can see examples of this kind of thing in the Sensei learning management plugin, which has a Course post type with other post types as children: lessons, quizzes, etc. You’ll probably want to explore different possibilities.

    I would not worry too much about the URL structure–just don’t alter it to the point that WordPress gets confused. If you make major changes to the site you will end up needing to create 301 redirects anyway, and you can use regular expressions to make your life easier there.

  • Hi,

    If you are looking for a temporary solution until the update, here:

     

    functions.php

    add:

    /**
     * Tests if any of a post's assigned categories are descendants of target categories
     *
     * @param int|array $cats The target categories. Integer ID or array of integer IDs
     * @param int|object $_post The post. Omit to test the current post in the Loop or main query
     * @return bool True if at least 1 of the post's categories is a descendant of any of the target categories
     * @see get_term_by() You can get a category by name or slug, then pass ID to this function
     * @uses get_term_children() Passes $cats
     * @uses in_category() Passes $_post (can be empty)
     * @version 2.7
     * @link http://codex.wordpress.org/Function_Reference/in_category#Testing_if_a_post_is_in_a_descendant_category
     */
    if ( ! function_exists( 'post_is_in_descendant_category' ) ) {
        function post_is_in_descendant_category( $cats, $_post = null ) {
            foreach ( (array) $cats as $cat ) {
                // get_term_children() accepts integer ID only
                $descendants = get_term_children( (int) $cat, 'category' );
                if ( $descendants && in_category( $descendants, $_post ) )
                    return true;
            }
            return false;
        }
    }

     

    wp-content/plugins/advanced-custom-fields/core/controllers/location.php

    Line 566-569 to:

    if( in_array($rule['value'], $terms) || post_is_in_descendant_category( $rule['value'], $options['post_id'] ) )
    {
        $match = true; 
    }
  • What will be the target version in which this bug will be fixed?
    This is a huge issue for us right now.

    Agreed. This is forcing us to downgrade/deliberately keep ACF out of date on every site we use it.

  • Meanwhile, I have put static content on the fron-end. Do you think that server may be overloaded by that many PHP requests at once?

  • While none of that complex code above seemed to work, simply using this did for me:

    <?php $date = get_field('my-date');
    $date2 = date("F j, Y", strtotime($date)); ?>
    
    <?php echo $date2; ?>
  • Hi @avatar1301

    Hmm… This would be a cool feature.

    I have popped in a feature request for Elliot to look into it.

    Thanks.

  • actually, to update. We do have two required fields, but they are hidden behind conditional logic.

  • I found a solution to my problem. I ended up using the wpmu_new_blog action hook to update the post meta when a new blog is created.

    Here is a basic idea of the code used:

    add_action('wpmu_new_blog', 'katart_update_new_blog', 10, 2);
    function katart_update_new_blog($blog_id,$user_id) {
       switch_to_blog($blog_id);
    
       $admin = get_userdata( $user_id );
    
       update_post_meta( 4, 'custom_post_meta', $admin->custom_user_meta );
    
       restore_current_blog();
    }

    This was a unique situation where I know the post ID. I hope this helps someone.

  • You’re not the only one experiencing this issue; my team and myself are as well.

    This issue was originally fixed in 3.40:

    [Fixed] Fix relationship search – Only search title, not content

    But it looks like it has resurfaced with the changes in WordPress 4.x. Hopefully someone on the ACF team will notice this thread.

  • Thanks for your reply. I admit to not understanding your hint.
    I’ve used meta_query as well but it does not support the sorting in combination with the custom field while having a where-clause with a different custom field. Or at least I didn’t get it to work.

    For now I’m building an own array with the data needed and do a multi-sort to get the result I need.

  • You can compare meta values using meta_query in your arguments before starting the loop.

    Check out the WordPress Codex on this topic. https://codex.wordpress.org/Class_Reference/WP_Meta_Query

  • Have you looked at the meta_query argument? You can pass this through your post arguments when you start the loop.

    https://codex.wordpress.org/Class_Reference/WP_Meta_Query

  • you need to check/correct this 2 lines

    $blubb = '[gallery ids="';
    $blubb .= '"]';

    and maybe you need to use do_shortcode instead of echo $blubb
    do_shortcode($blubb);

  • I updated the code from the first poster. You can’t check for is_admin, because it returns true (Ajax call is made to admin). See Documentation

    https://codex.wordpress.org/Function_Reference/is_admin

    //Custom redirected after creating a post
    function custom_redirect_function_name($post_id) {
    		$redirect = get_the_permalink($post_id);
    		wp_redirect($redirect);
    		exit;
    }
    add_action('acf/save_post', 'custom_redirect_function_name', 20);

    $redirect can be anything you want in my case it is as follow’s

    $redirect="/thank-you/?listing_id=$post_id"

    I wanted an url like this to process some further actions based on user choice (option to upgrade to different levels)

  • Sorry to resurrect this one. Seems I have come across this issue myself. So I have cleaned out all revisions and queried the db for the repeater field I am using:

    Here are the results

    79 30 page_blocks
    1997 3876 page_blocks 2
    2222 3882 page_blocks 3
    3311 3927 page_blocks 6
    5228 4002 page_blocks 1

    Each is a page in the site. So the process is:

    Change the field type in the ACF editor to Flexible Content

    Then specifically how do I figure out what serialized array to enter into each page?

  • maybe that works:

    <?php
    $blubb = '[gallery ids="';
    $images = get_field('acf-gallery'); 
    if( $images ): 
    $counter = 0;
    foreach( $images as $image ): 
    if ( $counter > 0 ) {$blubb .= ',';}
    $blubb .= $image['id'];
    $counter++;
    endforeach;
    endif; 
    $blubb .= '"]';
    
    echo $blubb;
    ?>
  • that is good. you see that it works ๐Ÿ˜‰
    the 8 is because you echo $row_count--;
    and testimonials_7_testimonial is the field name for the last row.

    now use something like that:

    $rows = get_post_meta( 348, 'testimonials', false ); // get number of rows, is inside a array
    $row_count = $rows[0]; //get row number out of array
    $row_count--; // because first row start with 0 not 1 subtract one from row number
    $lastrow_content =  'testimonials_'.$row_count.'_testimonial'; //get last row field
    $lastrow_head = 'testimonials_'.$row_count.'_testimonial_header'; //get last row field
    $end_testimonial_content = get_post_meta( 348, $lastrow_content, true );// get the last row value
    $end_testimonial_header = get_post_meta( 348, $lastrow_head, true ); // get the last row value 
    $last =  '<blockquote>' . $end_testimonial_content . '</blockquote><p>' . $end_testimonial_header . '</p>';
    echo $last;
  • Hi,

    Hmm… the code you are using is correct for a simple text based field type. If you are using a complex field i.e. checkbox, then the code will be a little different.

    Here is an example in the documentation that explains this: http://www.advancedcustomfields.com/resources/how-to-query-posts-filtered-by-custom-field-values/

  • Hi @mohamed,

    Possibly, there could be a syntax error in the function you have hooked to acf/fields/relationship/query filter and that is why the relationship field is not loading any posts.

  • Unfortunate, but I found my answer elsewhere.

    For those interested in a similar approached, please see: http://stackoverflow.com/questions/29234517/querying-advanced-custom-fields-want-to-paginate-the-results

  • When editing your page, you can also type this in your console :

    jQuery('.acf-button-delete').click();

    It will trigger a fake click on **every** delete button on image fields. Dont’ worry it won’t delete anything, just cancel the selection of the image that, you know, you can’t do anymore because the link is invisible… So you might select again other image fields.

    But if you are comfortable with debug tools, you can precise which field to apply the hack this way :

    jQuery('[data-field_key="field_54ca1472acea6"] .acf-button-delete').click();

    Hope this helps.

  • ok thanks – so I can get a specific row output like so…

    <?php 	
    	$rows =  get_post_meta( 348, 'testimonials', false ); // get all the rows
    	$end_testimonial_content = get_post_meta( 348, 'testimonials_4_testimonial', true );// get the sub field value 
    	$end_testimonial_header = get_post_meta( 348, 'testimonials_4_testimonial_header', true ); // get the sub field value 
    	$last =  '<blockquote>' . $end_testimonial_content . '</blockquote><p>' . $end_testimonial_header . '</p>';
    	echo $last; 
    
    	?>

    I also tried with end function but couldn’t get it to work, but as a fallback at least I have something on the page.

  • Ok now I got it to return the id’s. . using:

    <?php $images = get_field('acf-gallery'); if( $images ): ?> 
    <?php foreach( $images as $image ): ?>
    <?php echo $image['id']; ?>,
    <?php endforeach; ?> 
    <?php endif; ?>
    

    The above gets me this output:

    <div class="textwidget"> 
    315,
    314,
    305,
    306,
    308,
    309,
    307,
    313,
    311,
    312,
     
    </div>
    
  • Get to work with this:

    $field = get_field_object($field_key);
    echo $field[‘choices’][‘fr’];

    A question: are the field key ‘stable’. i.e., they are created/associated when a field is created and then the never changes?

    There is way to get the field key from the field name? I would like not to write specifically field keys in the source code….

Viewing 25 results - 17,001 through 17,025 (of 21,345 total)