Display multi-select box choices in a bullet list [closed]

From your comment below: This code displays the members selections but only as a comma separated list: <?php bp_member_profile_data( ‘field=Countries’ ); ?> // $countries_csl should contain something like ‘hufflepuff, hogwarts, heaven, hell’ $contries_csl = bp_get_member_profile_data( ‘field=Countries’ ); // convert the comma seperated list (csl) into an array by using explode( [delimiter], [string] ) $countries = … Read more

Defining multiple categories for showing latest posts

This is incorrect formatting of a PHP array: ‘cat’ => ‘4’, ‘5’, ‘6’, ‘7’ Use category__in and pass an array of category IDs: $args = array( ‘posts_per_page’ => 4, ‘category__in’ => array( 4, 5, 6, 7 ) ); See WP_Query for all valid parameters and how to format them correctly.

Woocommerce getting top level category parent and make all sub categories have the same template and menu

WP native function get_queried_object() can help you to get an ID of a currently displayed term. WooCommerce then includes this handy function: woocommerce_get_term_top_most_parent() (originated here on WPSE btw,) that will get it’s top-level parent term. I haven’t tested the following code but it should provide a good starting point: if ( ‘wedgwood’ == woocommerce_get_term_top_most_parent( get_queried_object()->term_id … Read more

How to break up php code to avoid echo

You have an extra “}”, there must be two such braces for two for each loops. Also you need to have endif; statement at end after endwhile. Parsing error may be due to extra “}”. Please try below code and let us know if it works. <?php $custom_terms = get_terms(‘videoscategory’); $other_custom_terms = get_terms(‘product_category’); foreach ($custom_terms … Read more

Add “alt” Attribute to GD Star Rating Tags

Add the attribute to each line of code that creates an img tag. In your text editor, search for lines that contain the string “<img”. Lines 241 and 273: $row->item_trend_rating = sprintf(‘<img class=”trend” src=”https://wordpress.stackexchange.com/questions/96226/%s” style=”https://wordpress.stackexchange.com/questions/96226/%s” width=”https://wordpress.stackexchange.com/questions/96226/%s” height=”https://wordpress.stackexchange.com/questions/96226/%s”></img>’, $gdsr->e, $image_bg, $set_rating->size, $set_rating->size); Becomes: $row->item_trend_rating = sprintf(‘<img class=”trend” src=”https://wordpress.stackexchange.com/questions/96226/%s” style=”https://wordpress.stackexchange.com/questions/96226/%s” width=”https://wordpress.stackexchange.com/questions/96226/%s” height=”https://wordpress.stackexchange.com/questions/96226/%s” alt=”https://wordpress.stackexchange.com/questions/96226/%s”></img>’, $gdsr->e, $image_bg, $set_rating->size, $set_rating->size, … Read more

Wp favorites posts by specific category? [closed]

This should do what you want: $have_favorite_posts = false; $favorite_post_ids = wpfp_get_users_favorites(); $cat = get_category_by_slug(‘news’)->cat_ID; // or if you want to use the category name (as tried in your code) // $cat = get_cat_ID(‘News’); if (! empty($favorite_post_ids)) { $fp_query = new WP_Query(array( ‘cat’ => $cat, ‘post__in’ => $favorite_post_ids, )); if ($fp_query->have_posts()) { $have_favorite_posts = true; … Read more

Display random image url from list of input values

Instead of echoing out these images, just store them as strings inside an array and choose one of the array items at random. <?php $headerimage_options = get_option(‘headerimage_options’ ); $images = array(); $images[] = ‘<img title=”‘.get_bloginfo(‘name’).'” src=”‘.esc_url( $headerimage_options[‘image’] ).'”/>’; $images[] = ‘<img title=”‘.get_bloginfo(‘name’).'” src=”‘.esc_url( $headerimage_options[‘image2′] ).'”/>’; $images[] = ‘<img title=”‘.get_bloginfo(‘name’).'” src=”‘.esc_url( $headerimage_options[‘image3′] ).'”/>’; $v = array_rand($images); … Read more

Add a select-option to the default widgets

The default widgets do not offer any hooks for that. You have to replace the default widget and add your field to the new class. The other option would be using JavaScript to insert the field, and a filter for ‘update_option_widget_’ . $widget->id_base to save the value. I think the separate class is the cleaner … Read more