New answers tagged

0

Thanks to LoicTheAztec who solved lots of questions and help people (in contrary of some jerks who just give bad notation randomly) here is the solution Original answer: https://stackoverflow.com/questions/53909349/allow-only-letter-on-specific-woocommerce-checkout-fields I just modify it for my needs. I think using JS script suit very well for this case ...


0

You will need to write some code for this I think. Start creating the new taxonomies and the query the right custom field to get the list of values. Use wp_insert_term() to add the new term. Then use wp_set_post_terms() to assign the terms to each post.


0

I know this question is old but for more info about the topic WordPress has built-in support for custom fields. If you have a custom post type then all you need is to include 'custom-fields' inside the support array inside of register_post_type as answered by @kubante Note that this option is also available for native post types like posts and pages you just ...


1

found the solution: $poster_path = get_post_meta($post->ID, "poster_path", $single = true); if( $poster_path == "" ){ echo '<img width="53" height="80" src="https://via.placeholder.com/370x556?text=No+Poster&000.jpg" />'; } else { echo '<img width="53"...


2

The meta value is a LONGTEXT field which can store about 4 GB (gigabytes) of characters (non-binary), but I can't help you test the limit and note that the number of characters that can be stored will depend on the character encoding. A quote from MySQL 8.0 Reference Manual: Note: The four TEXT (data) types are TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT. ...


0

I have managed to solve using the add_post_meta function instead of the meta_input property of the $postarr argument of the wp_insert_post function, as follows Instead of this $entry = [ "post_title" => "Some post title", "post_content" => "Some post content", "post_type" => "...


2

There's no way to do this without a bit of programming. You need to look at these pieces: A Wordpress hook like save_post lets you do something when a post is saved or updated wp_mail is how you send an email get_field is how you look at the value of an ACF field. You'd need to write some code to put them together how you want to, but the details of doing ...


0

found the solution the problem was the "posts_per_page" it made my website crash on that specific section and also in wp-config.php added define( 'WP_MEMORY_LIMIT', '256M' ); and it solved my problem


0

The thing you're talking about is called a custom meta box. They can be used to save post specific settings and data. You can create your own meta boxes with the help of add_meta_box() function. Here's a quick example. This would go to your (child) theme's functions.php file. Alternatively if you want to make the code theme independent, then create a custom ...


1

To add custom fields and save/update meta data to terms, you basically need to use these action hooks. custom fields html for new term {$taxonomy}_add_form_fields save custom field data for new term, get data from $_POST created_{$taxonomy} custom fields html for existing term {$taxonomy}_edit_form_fields save custom field data for existing term, get data ...


0

I can almost guarantee that you have the ACF field setting to return "Image URL" instead of "Image ID". This was the case for me anyway. Once I switched the setting (below) to "Image ID", my problem was solved.


0

check out this link. It will help you. follow it. It is quite simple https://pluginrepublic.com/add-custom-fields-woocommerce-product/#add-woocommerce-custom-fields-programmatically


0

this link will help you. It is from the Woocommerce repository only https://docs.woocommerce.com/document/add-a-custom-field-in-an-order-to-the-emails/


1

You could filter the the_post_thumbnail() function, which will dynamically show the assigned category image across all your custom post type, rather than using acf_save_post to save the category image in the post featured image meta field. By filtering the the_post_thumbnail() for your specific post type, this means if you change the image on category in the ...


1

As well as the answer from TheRecruit referencing the ACF plugin, you should also consider how your data is structured in terms of Categories, Tags etc as opposed to fields in individual posts. Another useful plugin is therefore CPT UI, which gives a nice, graphical interface to creating custom post types and taxonomies. So for instance you might use CPT UI ...


0

Here we showing an example to relative displaying custom post type in WordPress and in this code have args in arrays and using wp_query with the loop for getting post data. $args = array( 'post_status' => 'publish', 'posts_per_page' => 5, ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(...


1

As documented, the preview_post_link passes the post object as the second parameter. You can use this to get any fields that you might want: add_filter( 'preview_post_link', function( $preview_link, $post ) { $custom_field = get_field( 'custom_field_name', $post ); return $preview_link; }, 10, 2 // MUST be 2 to ...


2

Unless you're eager to program the functionality yourself, I would highly recommend "Advanced Custom Fields" (a plugin). It's very intuitive, and gives you the ability to add custom fields (duh!) to every post-type in your theme. This means that I could add a "Height"-field above my WYSIWIG-editor in my Post-editor.


1

This is just a basic php array question - not a WP question. function unique_authors ( $authors ) { $newArray = array(); foreach( $authors as $item ) { $itemArray = explode( ", ", $item ); $newArray = array_merge($newArray, $itemArray); } $newArray = array_unique($newArray); return $newArray; } $authors = ...


1

All I needed in my code for it to work is this: //get the repeater $car_repeater = get_field('repeater_name',$post_id); $first_row = $car_repeater[0]; //put [0] to get the first row of the repeater $first_car_model = $first_row['car_model']; //put [car_model] to get this field value in the specified row (first row) $...


1

I don't think you need to use save_post to save backend, as acf/save_post also saves when updating the post in the backend. I think (95% sure). Read the comments below in the code and see if this will help you create the custom post title you are after. Taking into account cars which only have 1 model, multiple models and no models. It's a start anyway. // ...


Top 50 recent answers are included