New answers tagged

0

Please go through serialize array concept in wp.In your postmeta it is storing data in serialised form if you are getting an array. Either you can loop through the array or to fetch a single record use the array key.


1

You got ARRAY echos because you saved array on post meta, Just check array values of meta data like: print_r( get_post_meta($post->ID, 'ptn_systeem', true) ); and echo it like: foreach( (array) get_post_meta($post->ID, 'ptn_systeem', true) as $option): echo $option . "<br>"; foreach;


0

I ended up having to switch to arrays instead of objects. Even that hasn't worked out as well as I hoped.


1

Copying from the answer here regarding variable scope Variables inside a function are only available inside that function. Variables outside of functions are available anywhere outside of functions, but not inside any function. Because of that, you need to add your $translations array within the kvkoolitus_load_comment_validation function, like ...


0

This is a simple PHP related question (and those are better asked at StackOverflow.com) and you can find if an index exists within a multi-dimensional array by iterating through it and matching. Something as: function wpse231889_has_user_voted( $user_id, $post_id ) { if ( !empty( ( $voters = get_post_meta( $post_id, 'voter' ) ) ) ) { foreach ( $...


0

Found the solution: $currentProducts = $wpdb->get_results("SELECT feedid, id, size, price FROM products WHERE shopid = $shopid", OBJECT_K); The OBJECT_K parameter makes an associative array with feedid as key: https://codex.wordpress.org/Class_Reference/wpdb#SELECT_Generic_Results


0

I wasn't able to get get_sites working, so here is a solution using wp_get_sites until further documentation is released on the new version. wp_get_sites returns a lot of data about the subsite, including creation and last modified dates. I turned my original $stageurl array into a multidimensional array and added registration date as a value. The ...


1

Using get_sites() in WP 4.6+ It looks like wp_get_sites() will be deprecated in WP 4.6. The new replacement is: function get_sites( $args = array() ) { $query = new WP_Site_Query(); return $query->query( $args ); } Very similar to get_posts() and WP_Query. It supports various useful parameters and filters. Here's what the inline ...


0

Not sure why you need to do that but, all you need is a loop: foreach ( $currentProducts as $currentProduct ) { $myNewArray[$currentProduct->feedid] = $currentProduct->size;//use whatever value you need }


1

I tried another solution and that did the trick. I found in the WooCommerce docs this little snippet: // Display 24 products per page. Goes in functions.php add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 24;' ), 20 );. It is overriding the settings in the customizer. I only have to change the number '24' to my liking.


0

I don't know what hook Woocommerce uses to add that customizer code, but in your functions.php you'll have to hook your own function on a later time, like this (the last number is the lower priority): add_action ('the_name_of_that_hook','wpse_280836_mycontrol', 99) Now in the function you are hooking, you must first remove the existing control and the add ...



Top 50 recent answers are included