How to fetch custom post type by variable date?

First, I assume you store event date in custom field properly. Native WP post published dates are really not meant for future events, since future dates are used for scheduling functionality and make posts non–public. From there it’s just a matter of putting together appropriate get_posts()/WP_Query to retrieve your set. Modern WP version allow very … Read more

get_terms and meta_value results blank

Here I’ve written a sql based function for you. By this you’ll get the terms ID with slug and name by passing the parameter’s as an array- function the_dramatist_get_terms_with_post_meta( $args = array() ) { global $wpdb; $default_args = array( ‘taxonomy’ => ‘category’, ‘meta_key’ => ”, ‘meta_value’ => ”, ‘post_type’ => ‘post’ ); $param = wp_parse_args( … Read more

How to make a new function that includes a template

Add your share button html to a template file in your theme: your-theme/share-buttons.php <a href=”http://twitter.com/home/?status=<?php the_title(); ?> – <?php the_permalink(); ?>” target=”_blank” title=”Tweet this!”><img src=”http://localhost:8888/wordpress/wp-content/uploads/2016/10/social-twitter.png”></a> <a href=”http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&amp;t=<?php the_title(); ?>” target=”_blank” title=”Share on Facebook.”><img src=”http://localhost:8888/wordpress/wp-content/uploads/2016/10/social-facebook.png”></a> <a href=”http://pinterest.com/pin/create/button/?url=<?php the_permalink(); ?>&media=<?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); echo $url; ?>” target=”_blank”><img src=”http://localhost:8888/wordpress/wp-content/uploads/2016/10/social-pinterest.png”></a> <a href=”http://www.bloglovin.com/e/?b=’ .get_bloginfo(‘wpurl’) . ‘&#038;p=’ .get_permalink().’&#038;t=”.get_the_title().””onclick=\’window.open(this.href,&quot;bloglovin_like&quot;,&quot;height=320,width=480,toolbar=0,location=0,menubar=0,scrollbars=0,status=0&quot;); … Read more

How to load jQuery in TOP of wp_footer?

To properly enqueue jQuery, it’s usually done with wp_enqueue_scripts, there’s no need to load it from cdn as jQuery library are provides in the wp-includes folder of WordPress. Only wp_enqueue_script(‘jquery’); is required. add_action(‘wp_enqueue_scripts’, ‘replace_jquery’); If you really want to replace jQuery with the cdn link, it’s better to register and enqueue it with this function.

“All posts” in the category widget

If the default category widget’s interface doesn’t offer what you want, there are roughly two courses of action: find another widget or adapt the existing one. The first would be outside the scope of this site, the second one is a bit too broad, but here’s what you would do for big adaptations: Build the … Read more

Adding theme option values as custom body class

Review how the variable scope works.. Let’s not add yet another global variable, instead we can e.g. fetch the option values within the filter’s callback: function wpse251261_custom_body_classes( $classes ) { // Get option values $rounded_corner_radio = of_get_option( ’rounded_corner_radio’ ); $gradient_radio = of_get_option( ‘gradient_radio’ ); // Assign new body classes $classes[] = esc_attr( $rounded_corner_radio ); $classes[] … Read more