Tag Info

New answers tagged

0

Ok, so after deeper research I've found out that values of some custom fields created by ACF are stored in MySQL database with some additional information like a:5:{i:0;s:6:"Aerial";i:1;s:6:"Nature";i:2;s:4:"Nude";i:3;s:6:"People";i:4;s:8:‌​"Wildlife";}. This happens when a custom field can store multiple values (like chechboxes). So I've edited part of my ...


1

UPDATE: Ok this should work, according to ACF's documentation: $args = array( 'posts_per_page' => -1, 'post_type' => 'page', 'meta_query' => array( array( 'key' => 'feature_on_front_page', 'value' => 'featured', 'compare' => 'LIKE' ), ) ); Your ...


-1

Try "posts_per_page" in place of "numberposts". numberposts is not a valid parameter of WP_Query. if you are using "ACF", then I think this will not work with WP_Query. This is not logical but I had same kind of bad experience. Try once


2

You are using the_ID() instead of get_the_ID(). Which is being echo. Also why you are using so many variable and pulling all the meta keys. I would like to suggest this code using get_post_meta(). $my_custom_field = get_post_meta(get_the_ID(), 'app_collection-postcode', true); $my_custom_field2 = get_post_meta(get_the_ID(), 'app_delivery-postcode', true); ...


0

I've actually made a plugin called Social Metrics Tracker which does exactly what you are trying to achieve. Please also feel free to read the source code on GitHub. To answer your questions: You are right that running an hourly cron task to update all of the posts would cause a problem with even just 200 articles because the server would make one GET ...


2

Add a meta box to your custom post type edit screen to contain your markup. Check the $pagenow global to only show it on post.php, not post-new.php, and check $current_user global for administrator role to exclude other user roles. Also, if you aren't familiar, check out the $wpdb class for your queries, and read up on using AJAX in WordPress. EDIT use ...


1

Have you read the documentation already? Seems it would be as simple asthe_field( "text_field" ); where text_field is the name of the field ofc.


0

There is a WordPress plugin that gives you all of your custom fields in a single, customizable spreadsheet view. It is fully editable and includes actions such as adding a custom field to all pages, copying the cells to other spreadsheet softwares, etc. It can be found at http://www.williambixler.com/product/custom-fields-spreadsheet/.


1

did you try to call like this: $args = array( 'post_type' => 'product', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'spec', 'value' => 'choice2', 'compare' => 'LIKE', ), array( 'key' => 'spec', 'value' => 'choice3', 'compare' => 'LIKE', ...


0

Maybe you're using the wrong tool to represent relations between posts. the custom post meta fields api is somehow inefficient for that task and has certain restrictions. I advice to have a look at the "posts to posts" plugin from pipin which is much more suited for that task.


1

I would strongly suggest to seperat the products and not to put them all into one array. Or even to create a taxonomy companies, but this is more up to the while design and maybe a bad idea. Nevertheless this is a nice question to solve, so lets play. So, the 'prefix_products' meta key is always an array of products. Now you need all companies, which sell a ...


1

It's not possible, you have to store that value separately, and then you'll be able to use it.


1

I packed everything together. Consider using wp_enqueue_script() to use the script. With this code, you will save all URLs as an array. See how I use get_post_meta() to retrieve the saved URLs. function save_custom_metabox($post_id){ if(!isset($_POST['source_post_metabox_nonce'])) : return; endif; if(!wp_verify_nonce( ...


1

If you would have created your own WP_Query, you could have done it this way: <?php $args = array( 'orderby' => 'meta_value_num', 'order' => 'ASC', 'meta_key' => 'price' ); $new_query = new WP_Query( $args ); ?> See the examples in the docs: https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters ...


1

The underscore prefix are private, these meta fields will be hidden and will not be shown as custom fields in the post backend screens. Those meta fields without the underscore prefix are public fields and shows up as custom fields in the post screens


1

Try this : // get_the_ID() will work if you're running within The Loop. $fieldA = get_post_meta( get_the_ID(), 'name_of_fieldA', true ); $fieldB = get_post_meta( get_the_ID(), 'name_of_fieldB', true ); if( $fieldA ) { echo "<a href='".$fieldA."' target='_blank' class='btn btn-primary fb-event'></a>"; } if( $fieldB ) { echo "<a ...


1

To expand on @pieter-goosen's comment, you do indeed want to use pre_get_posts. In your example, by using WP_Query, you're overwriting the entire query and just resetting most parts of it to default. In fact, you're probably not seeing a specific category of posts at all. You should be seeing all posts since that's the default of the WP_Query class. So ...


0

If you use update_post_meta, a meta field will be added to the post with the specified key. If the key exists, the meta field will be updated. If there are several meta fields with the same key, all of them will be updated. To add repeating fields, you must use add_post_meta with the third parameter set to false (it is already false as default). This way, ...


0

Since you're using the same key for all the values you can simply use: update_post_meta($this->current_post_id, 'assigned-sales', $response->records); This will store the whole array in a single meta entry with key of 'assigned-sales'. WordPress will update the value if it exists and create new one otherwise, no need to have logic for that. In ...


0

You will need an opening select tag that tells PHP it is an array. Something along the lines of the following should get you on your way... <?php // Display Fields add_action( 'show_user_profile', 'add_multiple_choice_dropdown ' ); add_action( 'edit_user_profile', 'add_multiple_choice_dropdown ' ); function add_multiple_choice_dropdown ( $user ) { ...


0

It's working, finaly. The link to the source and the code which worked out are below. http://wordpress.stackexchange.com/a/64124/69825 (Check for the Update #1 edit in the answer) It was through editing the content-single.php rather than through a filter in the functions.php file. I tried 2 or 3 recipes of each. I couldn't understand why they didn't work ...


1

I believe the primary problem in your code is the $custom_values is set after you try to use it (and you need to use the same variable name). Otherwise, it doesn't have a value when it's in post_class(). In fact, I'm surprised you're not getting an error. That variable needs to get the value before the call to post_class. <?php $custom_values = ...


1

Assuming we are viewing some king of single - post, page, custom post type etc. <?php $imgs_meta = get_post_meta( get_the_ID(), 'AP_post_image', true ); if ( '' != $imgs_meta ) { $imgs = explode( ',', $imgs_meta ); foreach ( $imgs as $src ) printf( '<img src="%s" />', esc_url( $src ) ); }



Top 50 recent answers are included