Display one random image from Media Library

I can’t comment due to lack of reputation, so I’ll address the issue rudtek mentioned. Personally, I never came across a host that disables PHP’s rand() function, but in case there is such a lousy host, you can opt for a more efficient way of doing things. What you can do is to get all … Read more

Retrieve array items without page ID

to get pages as array use get_pages() instead. now once we have a list we can check the size of list and split it. Let’s have an example: $allpages = get_pages( array( ‘child_of’ => $section_top_parent, ‘post_type’ => ‘section’, ‘depth’ => 1, ‘sort_order’ => ‘asc’ ) ); //check $allpages has any value if($allpages){ //calculate the array … Read more

Why are array_slice() and array_chunk() not working?

You need to do the slice on the results, not the arguments to the function. So: $arr = array( //$section_top_parent is the top parent of the custom post type “section” ‘child_of’ => $section_top_parent, ‘post_type’ => ‘section’, ‘title_li’ => NULL, ‘depth’ => 1, ‘sort_order’ => ‘asc’, ); $result = wp_list_pages($arr); $sliced = array_slice($result, 3, 5); wp_list_pages($sliced);

Adding an item to an anonymous array inside a filter?

I added the capabilities now through this code. I’m not happy with my solution and it would be great if someone could find a proper way to add to the filter. I would be honestly interested to know how to make it properly work. add_action( ‘admin_init’, ‘jp_add_atum_caps_to_shop_manager’); function jp_add_atum_caps_to_shop_manager() { if(!user_can( 217 , ‘atum_read_inbound_stock’)) { … Read more

Access to numerically indexed array in wpdb Class and undefined offset

var_dump($einzel); array(10) { [0]=> string(3) “144” [1]=> string(10) “21.05.2020” [2]=> string(10) “00.00.0000” [3]=> string(30) “Zugtag der Königsgilde Voitze” [4]=> string(14) ” ab 10.00 Uhr ” [5]=> string(0) “” [6]=> string(41) “Schützenhaus Voitze, Salzwedeler Straße” [7]=> string(6) “Voitze” [8]=> string(11) “Gaede,Joerg” [9]=> string(23) “[email protected]” } There are two same column names: ‘id’ and ‘name’. I worked … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)