Exclude parent categories from recent posts list

I was able to find a function that worked found here. First, I added the below code to my functions.php, which excludes the parent categories I do not want: function custom_get_the_category_list() { $categories = get_the_category(); $exclude1 = get_cat_ID( ‘Parent1’ ); $exclude2 = get_cat_ID( ‘Parent2’ ); $categories_list=””; foreach ( $categories as $category ) { if ( … Read more

WP Query with meta queries

You have to use “orderby” => “meta_value_num” and set a “meta_query” at the same time. Then choose the “meta_key” you want to order by. Try: $query = new WP_Query( array( ‘post_type’ => ‘some_cpt’, ‘posts_per_page’ => – 1, ‘meta_query’ => array( array( ‘key’ => ‘active’, ‘value’ => ‘1’, ‘compare’ => ‘=’, ) ), ‘meta_key’ => ‘ranking’, … Read more

How to use jQuery validation to set the search bar to accept only a specific input?

This code does the job (there is p instead of a) jQuery(function(){ jQuery(“.search-submit”).click(function(){ jQuery(“.error”).hide(); var hasError = false; var searchReg = /^[p0-9]+$/; var searchVal = jQuery(“.search-field”).val(); var searchLen = searchVal.length; var num1 = [‘1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9’]; var num0 = [‘0′,’1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9’]; if(searchLen < 3) { jQuery(“.search-field”).after(‘<span class=”error”>Enter at least 3 characters.</span>’); hasError = true; } else if(searchLen > … Read more

Finding post ID dynamically on click

What you’re looking to accomplish isn’t really pagination. That threw me off initially. You’re building a navigation that will be site-wide. If that’s the case, you can either capture the ID from the url (this is not very performant) or add the ID to the markup. This example shows you how to add the ID … Read more

How to create page with post content in it?

You might get away with shortcodes: add_shortcode(‘title’, function ($atts, $content = null) { $atts = shortcode_atts([ ‘id’ => null, ], $atts); $title=””; if (!empty($atts[‘id’])) { $title = get_the_title($atts[‘id’]); } return $title; }); add_shortcode(‘content’, function ($atts, $content = null) { $atts = shortcode_atts([ ‘id’ => null, ], $atts); $content=””; if (!empty($atts[‘id’])) { $post = get_post($atts[‘id’]); // … Read more