wp_generate_attachment_metadata for non-images files

wp_generate_metatadata() should create metadata for image, video, and audio file types. There is and if/elseif conditional in the source that limits the function to those three. However, the last line is: return apply_filters( ‘wp_generate_attachment_metadata’, $metadata, $attachment_id ); So you could use the wp_generate_attachment_metadata filter to generate the metadata you want. There are plenty of answers … Read more

Array is not working in Filter?

You cannot define something outside a function and then simply try to use it inside the function without calling it into the function. This is basic PHP and how functions work in general. You need to pass that specific something to the function or define that something inside the function or use a method to … Read more

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.