Add class to all meta boxes for a custom post type

After doing some playing around, I discovered this can actually be accomplished by defining the name of the hook I want to add the filter to via a variable. So if my $post_type_name is portfolio and my $box_id is piece_info, I can make a filter as follows: function add_meta_box_class( $classes ) { array_push( $classes, ‘custom-class’); … Read more

How to Retrieve All Category Images on Front-End

Your problem is too complex, you need to break it apart into multiple, simpler problems. If we don’t do this, the problem is much harder, and searching online for somebody who had exactly the same set of problems is much more difficult if not impossible. So lets do this with pseudocode, code written in plain … Read more

Need to Echo A Url path to show on a wordpress page

You can find that with somthing like the following add_shortcode( ‘url_path_number’, function ( $atts ) { // use an attribute or the current URL $a = shortcode_atts( array( ‘url’ => get_permalink(), ), $atts ); // get the path from the URL $path = parse_url($a[‘url’],PHP_URL_PATH); $parts = array_filter(explode(“https://wordpress.stackexchange.com/”, $path),function($v) { return $v !== ”; }); // … Read more

Get the image title and alt from custom query

At the top of your code, just after $large_image, you can add this : $image_alt = get_post_meta((int)get_post_meta( get_the_ID() , “_thumbnail_id” , true ), ‘_wp_attachment_image_alt’, true); $image_title = get_the_title((int)get_post_meta( get_the_ID() , “_thumbnail_id” , true )); The alt for attachment is stock in post_meta (_wp_attachment_image_alt), the title is a post_title. And then your replace the value in … Read more

Getting data from serilized array

Use this: $next_in_line = get_post_meta(esc_attr($product->get_id()), ‘_next_in_line’, true); print_r($next_in_line[‘user_id’]); print_r($next_in_line[‘product_id’]); Let me know if works.