Support

Account

Forum Replies Created

  • You need to use LIKE to match products with recipes and you need to add an array for each product you’re trying to match. Also, remember to put the ID inside parentheses (“”) otherwise you will match “12” with “123”.

    // GET RECIPES THAT HAVE A RELATIONSHIP TO PRODUCTS ON THE CURRENT PAGE - manually
    $recipes_manual_meta_query = array(
    	'post_type' => 'recipes',
    	'meta_query' => array(
    		'relation' => 'OR',
    			array(
    				'key' => 'products_under_recipes',
    				'value' => '"' . $products[0]->ID . '"',
    				'compare' => 'LIKE'
    			),
    			array(
    				'key' => 'products_under_recipes',
    				'value' => '"' . $products[1]->ID . '"',
    				'compare' => 'LIKE'
    			)
    	)
    );
    

    This is the manual solution (without going over the array of products for page), to show you clearly what the meta_query should look like.

  • Hi,

    you have to write a complex meta_query to get this working. I’ll try to make it clear by explaining it in steps.

    First, I’ve rewritten your code a bit to eliminate french words, just so it’s obvious what we’re doing. I’m on the “Work” page here. This is the setup before we get into code:

    CUSTOM POST TYPE Products
    – Product 1
    – Product 2
    – Product 3
    CUSTOM POST TYPE Recipes
    – Recipe 1 (has Product 2 an Product 3 linked)
    – Recipe 2 (has Product 2 linked)
    – Recipe 3 (has Product 1 and Product 2 linked)
    PAGE Work
    – has Product 1 and Product 3 linked

    … now you want to display all the Recipes that are shared between the current page (Work) and the Recipe. The correct result will be Recipe 1 and Recipe 3.

    The easy first step (you’ve done it already) is to get products for the current page and their ID’s into an array:

    // GET PRODUCTS FOR THE CURRENT PAGE (two products)
    $products = get_field('products_under_work');
    // var_dump($products); // returns "Product 1" (id=15) and "Product 3" (id=19)
    
    // GET AN ARRAY OF PRODUCT ID'S ONLY
    $product_ids = array();
    foreach($products as $product) :
    	array_push($product_ids, $product->ID);
    endforeach;
    // var_dump($product_ids); // 15,19
    

    (continued in next post)

  • Hi,

    Are you using a custom post type, page or post?

  • Hi,

    I’m using it with WP 3.9 without any problems. Try disabling the Wildhorn theme and see if that makes ACF appear.

  • Try disabling the Post Types Order’s default ordering – and then just manually query as described on the settings page. It should help (works for me).

    There’s also another ordering plugin you could try – WonderbyPress http://codecanyon.net/item/worderbypress/3900525 .

  • Hi,

    you need to specify your first meta_query in more detail.

    
    $today = date('Ymd');
    $args = array (
        'post_type' => 'events',
        'order' => 'ASC',
        'cat' => '2',
        'meta_query' => array(
    	     array(
    	        'key'		=> 'event_date',
    	        'compare'	=> '>=',
    	        'value'		=> $today,
    	    )
        ),
    );
    

    This is an approximation of the code based on what I can gather from your example. The important part is just to add the ‘meta_query’ in your standard query and you’ll be set.

  • Try doing a var_dump($terms) … then var_dump($custom_field) . What does it say?

    So you’ll at least know where you get stuck.

  • Hi,

    I’m using WPML – http://wpml.org/ – on a complex project and everything translates great. It has a logical interface for translating anything – I’m translating a lot of ACF fields without problems (and of course all the regular WP stuff).

    I’ve done a lot of research and WPML always came recommended as the most reliable solution. It does add some overhead, but once I cache everything properly, it’s not a problem.

    If I would make only a two-language website and the editors could all handle english captions for backend, I would rather create duplicate fields for everything. But in this case, the site would have to be an exact mirror between languages.

    If you want the ability to only translate certain things and have multiple languages, I think WPML is your best bet. It costs a bit, but it’s a multi-site license. There might be something faster out there, but I’d be worried about support – once something changes, are they big enough to update everything quickly? WPML is so widely used, I’m sure they are under enough pressure to provide up-to-date updates for all the major plugins, ACF included.

    If you do find something lighter and faster, let me know!

  • Hi,

    the Gallery field is a custom addon – a separate plugin you need to install.

    It’s also a premium plugin, so you need to buy it first. One license is good for multiple websites (for the current version of ACF at least). You can buy the plugin here: http://www.advancedcustomfields.com/add-ons/gallery-field/

  • Hi,

    if you want single-page pagination, you could use a jQuery plugin, for instance http://flaviusmatis.github.io/simplePagination.js/ . You can feed it your entire gallery and it will do the heavy lifting for you.

    If you want multi-page pagination (where each page shows part of your gallery), you can use any simple php approach for pagination – and just query the part of the gallery you need on each page.

    Unless you’re experienced with PHP, I suggest you take the first approach.

  • Hi,

    when you’re editing your custom date field, you can see “Display format” on the bottom. This will format the display of the date.

    http://www.advancedcustomfields.com/resources/field-types/date-picker/

    If you’re setting the format in wp backend, use JS date format, but you can also format the date later in PHP – use the code from example

    $date = DateTime::createFromFormat('Ymd', get_field('date_picker'));
    echo $date->format('d-m-Y');
  • Hi,

    yes, I’m ok, this was more of a bug-report. I think the best solution would be to filter out these characters on the automatic js filling of the field (where you lowercase, replace spaces etc.). I would never intentionally use foreign characters in a field name, but when I’m filling the fields quickly I don’t always remember to check the generated field name.

    I have a script for my cms that does it while preserving the most common european characters – I’m attaching it.

    Thanks for your help!
    Jure

  • Hi,

    I deleted the four rows in yellow in the attached pic DB1.

    The situation now:
    – ACF field name is “year_of_release”
    – when I edit an existing post, the field shows up as empty (doesn’t pick up string “Again” from the database)
    – when I type a new value in the existing post, the field saves OK – the database now looks like DB2 image (yellow fields are new)
    – when I add a new post, the field saves OK, the database now looks like DB3 image (yellow fields are new)

    I’m guessing the double fields are working and the single one (after rename) isn’t. After renaming my UTF8 character, it only saves a single field, so it isn’t working.

    Btw – why do the fields save twice in the DB? Post locking / versioning?

    Bye,
    Jure

  • Hi,

    this is how it looks in the database. It might be that your checking is stricter than WPs?

    Thanks for looking into it,
    Jure

Viewing 14 posts - 26 through 39 (of 39 total)