Hot answers tagged

5

This is more of a general srcset and browser question, not a WordPress specific question. However, in general, you can't predict what browsers will do with the srcset information. For your specific example, it appears that you failed to clear the cache completely between your reloads. Note the 304 response indicating that your browser already has the image ...


5

You are returning inside your loop - so it returns on the first iteration, giving you one result only. You should build a string inside your loop instead, and only return when the loop is over. Something like $featured_properties = ''; if( $featured_query->have_posts() ): while( $featured_query->have_posts() ) : ...


4

I guess you mean add_action( 'pre_get_posts', 'private_groups' ); add_action( 'pre_get_posts', 'search_results' ); add_action( 'pre_get_posts', 'name_profiles' ); versus add_action( 'pre_get_posts', 'combined_into_single_callback' ); You can just check the difference using e.g. memory_get_usage() and timer_stop(). Many good plugins out there to help ...


3

You got it quite right, but with a few minor problems. First, please use a uniqe prefix for your functions and values - opacity or meta_save are quite generic and could be used by other authors. Second, the part where you get the meta opacity was missing, I added it for you - just retrieve the meta value from the current post. Third, I then created a ...


3

EDIT I have played around with a possible solution to your issue. We can try the following Add our own action to template_redirect where we do the following Check that the current request is a paged single post page and that we do not have the <!--nextpage--> tag in the post content. If everything checks out in our condition, we will do a manual ...


2

human_time_difference() will not work here as it returns a string in a human readable form. However, we can use some of the logic used there to construct a workable function You can try the following: (Untested) function get_custom__time_diff() { global $post; // Get the current time $current_time = time(); // Get the post date ...


2

You can create new schedule times via cron_schedules: function my_cron_schedules($schedules){ if(!isset($schedules["5min"])){ $schedules["5min"] = array( 'interval' => 5*60, 'display' => __('Once every 5 minutes')); } if(!isset($schedules["30min"])){ $schedules["30min"] = array( ...


2

The code you have provided is incomplete. Not sure if that is the only code you are using to achieve what you want. So, besides first code block which you have provided, bellow I am adding all rest of the code which is required to show the new field on backend in 'Order Details' box and make it editable through custom fields. Please note, in your second code ...


2

This is quite basic but should help you on your way. //Get posts for the current week $args = array( 'date_query' => array( array( 'year' => date( 'Y' ), 'week' => date( 'W' ), ) ) ); //Check for search query if ( isset( $_GET['s'] ) ) { $args['s'] = $_GET['s']; } //Create these variables for ...


2

Basic Filtering This is just a simple example and would work if you're just using it for editors that might slip up here or there and put in a swear word by accident. However, if you have to worry about people trying to "spoof" their words for example "focker, fuker, etc" then you'll probably need something more complex. // Basic Implementation function ...


1

So I've found this WP_Image_Editor in the CodeX. Basically by adding the code below it should automatically resize an image :) Code: $image = wp_get_image_editor( 'cool_image.jpg' ); // Return an implementation that extends WP_Image_Editor if ( ! is_wp_error( $image ) ) { $image->resize( 300, 300, true ); $image->save( 'new_image.jpg' ); } ...


1

You didn't specify how many arguments your function accepts when you used add_filter: add_filter( $tag, $function_to_add, $priority, $accepted_args ); Your code only passes a $tag and a $function_to_add, but it doesn't tell WordPress what priority it should be, or how many accepted arguments your function takes. You need to fix that. If you don't provide ...


1

Have a look at the Codex about "Using Gravatars". There you´ll find a part about "Checking for the Existence of a Gravatar" which works like this: The trick to do this is to specify "404" as the default. In this case, the gravatar service will return a 404 error if no gravatar exists, instead of returning some default image. A real image will get a 200 ...


1

Unfortunately there is no hook available to remove that "Our Bank Details" text. But, you can hide the default which is added and un-intended area by placing following rule in your theme's style.css file: .woocommerce-order-received .woocommerce h2:nth-of-type(2) { display: none; } Then to have "Our Bank Details" at intended place, simply go to ...


1

Here's another way to do it, utilizing get_template_part of wordpress function include_file($atts) { $a = shortcode_atts( array( 'slug' => 'NULL', ), $atts ); if($slug != 'NULL'){ ob_start(); get_template_part($a['slug']); return ob_get_clean(); } } add_shortcode('include', 'include_file'); ...


1

At first - do not use extract. It's very bad code style and is also depracated in core. Every time your foreach loop run, you override content of $output because you assign to this variable new content. What you want is to concatenate new list item with existing ones. This can be done using concatening assignment operator: $output .= '<li ...


1

You need to recurse into the shortcode content ($m[5] as returned by get_shortcode_regex()), the standard way being to use preg_replace_callback(): public function wrapShortcode( $content ) { $content = preg_replace_callback( '/' . get_shortcode_regex() . '/s', array( $this, 'wrapShortcodeCallback' ), $content ); remove_filter( ...


1

You are mixing html and php content. You should write it like this: <?php function thumbImg() { if ( has_post_thumbnail() ) { the_post_thumbnail( array(54,54) ); } else { echo "<img src='{$data['featured_img']}' alt='".get_the_title()."' />"; } } ?> This way, you don't need to open and close again the php tag.


1

This question has been answered on Stack Overflow before: http://stackoverflow.com/a/14626254/844732 add_action( 'admin_head', 'check_page_template' ); function check_page_template() { global $post; if ( 'page-homepage.php' == get_post_meta( $post->ID, '_wp_page_template', true ) ) { // The current page has the foobar template assigned ...



Only top voted, non community-wiki answers of a minimum length are eligible