Problem display

Enclose the while loop with a conditional: $the_query = new WP_Query( array( ‘p’ => $id_film) ); if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ): $the_query->the_post(); // regular output endwhile; wp_reset_postdata(); } else { echo ‘No movie data’; }

How to display search query as formatted text?

You’ll probably want filter out some parameters, change the order they’re displayed, etc – but this should get you started: $s = “/?s=Search&property_city=las-vegas&property_location=Nevada&min_price=20000&max_price=500000&beds=2&baths=3&min_area=1000&max_area=1000000&property_type=apartment&s=Search&apor=Any&apvr=Any&post_type=property”; parse_str($s,$parts); foreach ($parts as $key => $value) { $name = ucwords(str_replace(“_”,” “,$key)); echo “$name: $value<br />\n”; } You can probably just use foreach ($_REQUEST as $key => $value) { unless there’s a … Read more

Grouped Custom Meta Fields without plugin

stick with cmb2 — there is another method of displaying and then saving meta data, but it’s a PAIN and loads your functions file. the plugin pretty much has no effect on the front end of the site — it’ll also make your meta boxes a lot cleaner and consistent-looking

Assign class to Drop Down Selections in WooCommerce Products Custom Fields

You can do in the following way! Create an array of CSS class names and message values $colors_stings = array( ‘Message one’ => ‘message_color_green’, ‘Message two’ => ‘message_color_red’, ‘Message three’ => ‘message_color_blue’ ); Check if message string exist in array then assign CSS color class to variable. $css_class = isset($colors_stings[$product_status]) ? $colors_stings[$product_status] : ‘message_default_color’; Complete … Read more

Too many if’s and else if’s ?? – Must be better way [closed]

This question probably belongs to Code Review. Anyway, you can fill your event properties inside an array, which you can iterate: $events = array( ‘opening’ => array( ‘time’ => ‘…time here…’, ‘formatted_time’ => ‘…time here…’, ‘label’ => __(‘Opening:’), // or ucfirst($type) if you want… ), ‘closing’ => array( ‘time’ => ‘…time here…’, ‘formatted_time’ => ‘…time … Read more

How much worse is querying custom fields compared to custom taxonomies, quantitatively

The trouble with meta queries is they require an additional join per filter. Say you have a property site, and you’re searching by location, rooms and price. That’s three joins. If you were using taxonomies, just two (terms and term_taxonomy) – no matter how many filters. The other reason taxonomies tend to beat meta queries … Read more

Appending an ACF custom field to the page title

If you need to append something to EVERY post_title you have, you should: Make your loop with WP Query, check Codex Then, use get_the_ID, to get the specific post ID, check Codex Then, use the ID to get the ACF field from that specific post like get_field(‘name-of-the-field), check the documentation Don’t forget to use wp_reset_query(), … Read more

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