Dynamically adding filters

I think you are on the right track, but that last part is messy. You are using the bw_add_markup_class function for two different purposes : to return the classes that you want to add to list the context of the filters that you want to call If I understand well want you are trying to … Read more

WP Page Options Array

After much experimentation I resolved my own question and this answer might help somebody. function mmm_select_field( ) { $options = get_option( ‘mmm_settings’ ); $buttons = array( ‘Bold’ => ‘bold’, ‘Italic’ => ‘italic’, ‘Underline’ => ‘underline’, ‘Superscript’ => ‘superscript’, ‘Align Left’ => ‘alignleft’, ‘Align Center’ => ‘aligncenter’, ‘Align Right’ => ‘alignright’, ‘Bullet List’ => ‘bulletlist’, ‘Number … Read more

Get a list of ACF Repeater-Fields as array

Holy loop attack Batman! I think you can simplify this a lot: $the_posts = get_posts( array( ‘posts_per_page’ => ‘-1’, ‘post_type’ => ‘artists’, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘date’, ‘value’ => date( ‘Ymd’ ), ‘compare’ => ‘<‘, ), ) )); $the_list = array(); foreach ( $the_posts as $the_post ) { if ( … Read more

Get css class of menu item in custom menu structure

What you’re getting is an array so you need to implode() them – the Walker_Nav_Menu has something like this: $class_names = esc_attr( implode( ‘ ‘, apply_filters( ‘nav_menu_css_class’, array_filter( $classes ), $item ) ) ); So you can modify your foreach to implode them in a similar fashion $class = esc_attr( implode( ‘ ‘, apply_filters( ‘nav_menu_css_class’, … Read more

Add key and value to an array in another file

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.

array_rand not working correctly?

Getting a single random post would be far more efficient than getting all posts, then plucking a random post from the query. Here’s an updated WP_Query instance using ‘orderby’ => rand: $args = array( ‘orderby’ => ‘rand’, ‘posts_per_page’ => ‘1’, ‘paged’ => $paged, ‘post_type’ => ‘Didyouknows’, // Post type names should never use capital letters, … Read more

Separate array output into a

The foreach loop isn’t needed. This will list out all job categories separated by a comma. $terms = wp_get_post_terms( $job->ID, ‘job_listing_category’ ); echo implode( ‘, ‘, wp_list_pluck( $terms, ‘name’ ) ); // Marketing, Sales, Finance, Support

Multidimensional Array

The multidimensional array in this case is a multi-dimensional associative array, or a key-value pair. The key being ‘status’ and the value being your array of strings. In the conditional check you have attempted to access values by a numerical index, which in this case do not exist as nothing has been set to use … Read more

How can I split my query result in 2 arrays?

There’s no need to split the array, you can just close the first div once you’ve counted up to four elements of the array. $args = array( ‘post_type’ => ‘event’, ‘meta_key’ => ‘date’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘posts_per_page’ => 8, ‘meta_query’ => array( ‘key’ => ‘date’, ‘value’ => date(‘Y-m-d’,strtotime(“today”)), ‘compare’ => ‘>=’, ‘type’ … Read more

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