Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Hi @NWTD

    Try removing ACF from the equation by changing your ‘orderby’ value to ‘title’. Do the posts order by title? Perhaps also try ‘rand’.

    If these work, perhaps try 'orderby' => 'meta_value' (without the ‘_num’)

    Also, check that you don’t have any ‘pre_get_post’ filters that are modifying the args

  • Hi @bgomski

    Can you please edit the above to clearly describe the issue. There are many parts to your query that are confusing:

    1. I have custom field group (repeater) on page A
    Is this a field, or a field group?

    2. one of those fields is a “True / False” box.
    Is this a sub field or normal field?

    3. What is ‘all of the content from that field group post’

    4. What is page B?

    5. How do you access page A and page B?

    6. How does page B know of page A?

    Thanks
    E

  • Hi @andrefelipe,

    Thankyou for your request! It has been added to a report for Elliots attention

    Have a nice day

  • Thanks for the response @elliot.

    My apologies for not clearing this up sooner. My query displays the posts. They’re just not ordered by the meta_key defined in the query. The meta_key is a datepicker from ACF.

    Here’s how the query looks on the front end: http://imgur.com/ANmN8ft

    Notice how the dates are not in order? The posts are in order by the post date, not the date set forth by the advanced custom field.

    I hope that helps to clear up any confusion.

  • Hi @NWTD

    Thanks for the screenshot. Can you confirm that this setting has never been changed and that all posts have saved in the correct format?

    Perhaps you have another issue in your WP_Query args. The best way to find the issue is to remove parts from the args one at a time until the issue resolves itself.

    
    $args = array(
    		'post_type' => 'portfolio',
    		'posts_per_page' => -1,
    		'meta_key' => 'date_received',
    		'orderby' => 'meta_value_num',
    		'order' => 'DESC'
    	);
    	$query = new WP_query($args);
    		
    	var_dump( $query->have_posts() );
    

    Perhaps remove the orderby and order? perhaps remove the meta_key also?

    Thanks
    E

  • Hi @Sarah

    Perhaps you could hook into the update_value filter and escape all values before they are saved to the DB?

    The filter in question can be read about here:
    http://www.advancedcustomfields.com/resources/filters/acfupdate_value/

    Thanks
    E

  • Hi @Twansparant

    The above code is not a WP_Query, therefore the above code would not work,

    Thanks
    E

  • Hi @matoma16

    Edit your repeater field and find the image sub field. The image sub field will show an option for ‘required’. Set this to ‘Yes’ and your image fiedl will be required.

    Thanks
    E

  • Hi @Ionut Staicu

    Yes, multiple field groups can’t be joined by tabs (yet).
    Perhaps in the future, I can add this in, but the WP metaboxes make this idea quite complicated

    Thanks
    E

  • @Sarah
    i added it from a custom plugin like this:

    add_action( 'wp_enqueue_scripts', 'my_enqueue_styles_scripts' );
    function my_enqueue_styles_scripts() {
        wp_enqueue_script( 'acf-custom-validation', plugins_url( 'inc/js/acf-custom-validation.js', __FILE__ ), array( 'acf-input' ) );
    }
  • I am still very interested in finding a solution to this however Elliot, what you stated above went right over my head. It is possible you could consolidate it into a working technique…

    Any help is greatly appreciated.

  • Trying to add some custom .js validation (as per the above) on a front end form, but can’t get it to work. Where should this code go?

    I’ve tried adding inline on the form page, and also as a separate script via wp_enqueue_scripts action, but no joy?

    Thanks!

  • Thanks. I have done some initial testing.

    If one has a front end form with text field, a malicious user could potentially input <script>alert('You've been hacked');</script> and if echo get_field or the_field is used to output that field, the script will then run.

    As far as I understand it, one would therefore use echo esc_html (get_field(..)); to escape the data on output (or esc_attr, esc_url, etc as appropriate)

    I think this needs highlighting right at the top of your Front End form ‘how-to’!

    What I have yet to establish is whether any additional sanitization needs to be done before the data is input to the database. According to http://codex.wordpress.org/Class_Reference/wpdb#UPDATE_rows, $wpdb->update takes raw input values (they should not be SQL escaped) – so perhaps that’s enough?

    The only thing that bothers me is that potentially one could then still end up with malicious js script in the db – maybe the answer is to use esc_html on input to db as well as output.

    Any further thoughts welcome…

  • Hi Elliot,

    Would it be possible to use the builtin WordPress $paged function instead?
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;

    And after the loop call the default pagination functions like this?

    next_posts_link();
    previous_posts_link();

    An working example would be very welcome for this indeed.
    Thanks a lot!

  • Thanks for quick reply! Tried deactivating all plugins and didn’t work. However did a clean install of WordPress + same theme and it worked ok, so the problem must be on my end :/

  • Can you perhaps make the ACF function ‘Global’ as per something similar here:-

    http://stackoverflow.com/questions/9911413/access-to-a-function-declared-within-an-anonymous-function

  • First, Awesome work on ACF!
    Just a Note: It looks like metaboxes aren’t honoring “Screen options” to turn on or off the metabox. While this works when the user clicks “Screen options” to hide a given metabox (jQuery toggles display:none/block), it’s not remembering the user set preferences.

    I’ve tracked the line down for you at line #714 in everything_fields.php. It looks like there is no initial style=”display: …” set. This needs to pull the user’s set value or leverage WP’s hidden_meta_boxes filter to know what the initial value is/should be.

  • I wasn’t setting the ID into the my_post array.

    I’ve added that in and it works now for both new and updated posts. Weird how it updated for existing items but now new items.

    	if ( get_post_type( $post_id ) == 'equipment' ) {
    
    		$my_post = array();
    		$my_post['ID'] = $post_id;
    		$my_post['post_title'] = get_field( 'name', $post_id );
    		
    		wp_update_post( $my_post );
    
    	}
  • Hi Elliot,

    I’ve updated accordingly, but the problem remains. I’ve made a video of how it behaves and copied the code I’m using below. It all seems pretty kosher. Could it be something to do with the post_id not being ready for new posts?

    http://www.youtube.com/watch?v=tzkWP_SBRjU

    function my_post_title_updater( $post_id ) {
    
    	if ( get_post_type( $post_id ) == 'testimonial' ) {
    
    		$my_post = array();
    		$my_post['post_title'] = get_field( 'name', $post_id ) . ' - "' . substr(get_field( 'testimonial', $post_id ), 0, 30) . '..."';
    		
    		wp_update_post( $my_post );
    
    	}
    
    	if ( get_post_type( $post_id ) == 'equipment' ) {
    
    		$my_post = array();
    		$my_post['post_title'] = get_field( 'name', $post_id );
    		
    		wp_update_post( $my_post );
    
    	}
    
    }
     
    // run after ACF saves the $_POST['fields'] data
    add_action('acf/save_post', 'my_post_title_updater', 20);

    Thanks,
    Andy.

  • Hi @qstudio

    If this week goes well, ACF5 should be out in beta by friday!

    Thanks
    E

  • Hi @caju

    New topics are only allowed to be added from Monday to Friday. In the future, please do not jump onto another thread and post your question. Instead, wait until the support forum hours are open.

    As for your question, the file field does not return the filesize data. I’ll add this to the to-do, but for now, you can load it like so:

    
    $attachment = get_field(’tile_package’);
    $filesize = size_format(filesize( get_attached_file( $attachment['ID'] ) ));
    

    Thanks
    E

  • Hi,

    This appears to do the job. Expanding on the theme of testimonials, it will update the actual WP post title based on two ACF fields, ‘name’ and ‘testimonial’. It will set the title as follows…

    NAME – “First 20 characters…”

    function my_post_title_updater( $post_id ) {
    
    	if ( get_post_type() == 'testimonial' ) {
    
    		$my_post = array();
    		$my_post['post_title'] = get_field( 'name', $post_id ) . ' - "' . substr(get_field( 'testimonial', $post_id ), 0, 30) . '..."';
    		
    		// Update the post into the database
    		wp_update_post( $my_post );
    
    	}
    
    }
     
    // run after ACF saves the $_POST['fields'] data
    add_action('acf/save_post', 'my_post_title_updater', 20);

    You could sharpen up the shortening of the testimonial, but everything I need to solve the challenge I had, seems to be achievable with this code.

    For prosperity, I’m using the ‘Custom Post Type UI‘ plugin to register the custom post types.

    Thanks for everyones help and input.

  • Hi Elliot,

    Thanks for getting back to me.

    Your suggestion sounds about right – but I don’t understand why on some pages the field types are loading normally – I have Query Monitor plugin installed and this informs me of slow or heavy queries – and it does not complain at all.

    I have put in place a temporary fix ( manually re-creating the selects from the data ) – this is good enough for a few weeks – when is V5 due out – I’d be happy to wait?

    Cheers 🙂

    Ray

Viewing 25 results - 18,901 through 18,925 (of 21,364 total)