Show/Hide Featured Image or replace it with custom field [closed]
I’m pretty sure you want something like this: $myfield = get_post_meta($post->ID, ‘short’, true); if ($myfield) { echo do_shortcode($myfield); } else { the_post_thumbnail(); }
I’m pretty sure you want something like this: $myfield = get_post_meta($post->ID, ‘short’, true); if ($myfield) { echo do_shortcode($myfield); } else { the_post_thumbnail(); }
There is a way to do it. Just include that CSS inside header before wp_head() with internal css. And then add the Source using PHP like below <style> .about-img:after { background-image: url(<?php bloginfo(‘template_directory’)?>/img/tola.jpeg); } </style>
A 404 page should never be indexed. A 404 response is an error message indicating that a page doesn’t exist. If your site is sending traffic to a 404 page, Google won’t index the page. This is an expected behavior! If your “404” page isn’t returning a 404 error, then it’s not a 404 page. … Read more
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’; }
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
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
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
<?php $cat = get_post_meta( get_the_ID(), ‘cat_page’, true ); $args = array( ‘category_name’ => $cat, ‘meta_key’ => ‘niveau_chiffre’, ‘orderby’ => ‘meta_value_num’, //Since we’re dealing with numbers ‘order’ => ‘ASC’, //’meta_query’ => array( // array( //’key’ => ‘niveau-chiffre’, //’value’ => ‘niveau-chiffre’, Don’t give a value because we’re not looking for a specific one //’compare’ => ‘>=’, We’re … Read more
You can simply store the meta as an array… Also to hell with add_post_meta… I never use it. update defaults to add if the meta doesn’t exist for the post. update_post_meta($post_id, “_event_musikstil”, $event_musikstil); wordpress will store the value as a serialized array then so just retrieve it like get_post_meta($post_id, “_event_musikstil”, TRUE); Hope this helps. Another … Read more
could be a question of string concatenation – try (untested): <a href=”‘.get_permalink().'” title=”‘.get_the_title().'”><img src=”‘. get_bloginfo(‘template_directory’).’/timthumb.php?src=”.$thumb.”&h=100&w=600&zc=1&q=100&a=”.get_post_meta($post->ID, “thumbcrop’, true).'” alt=”‘.get_the_title().'” /></a>