How to pull latest posts from a specific category

I figured it out, had a lot of syntax issues and open php tags. <?php // the query $the_query = new WP_Query(array( ‘category_name’ => ‘local-news’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 5, )); ?> <?php if ($the_query->have_posts()) : ?> <?php while ($the_query->have_posts()) : $the_query >the_post(); ?> <div class=”card-body pb-0″> <div class=”latest_news_cont”> <a href=”<?php the_permalink() ?>”> <?php … Read more

Using has_term() function for category-subcategory structure

Reading this solution here: has_category() for parent category I tried a similar approach and instead of hammering down all the terms I utilized the above solution to leverage the category term or any of its sub-categories: add_filter(‘the_content’, ‘ssws_add_content’); function ssws_add_content($content) { $cat_id = get_cat_ID(‘accommodations’); $children = get_term_children($cat_id, ‘category’); $ssws_custom_text=”<h1>Accomodation</h1>”; if (is_single() && (has_category($cat_id) || has_category($children))) … Read more

No templates for condition page.php Elementor

I finally figured out the problem and it was nothing related to the template files. I had dequeue jquery and instead re-enqueued my custom jquery as Jquery instead of jquery which is used by Elementor and that was the cause of the issue. This is how my code was. wp_dequeue_script(‘jquery’); wp_deregister_script(‘jquery’); wp_register_script(‘Jquery’, get_template_directory_uri().’/vendor/jquery/jquery.js’, false, ‘3.4.1’, … Read more

Manually adding current_page_parent to wp_list_pages()

By default wp_list_pages() uses the Walker_Page class to create the HTML list, and there’s a filter in there—page_css_class—for the CSS classes. You should be able to do something like this: /** * Filters the CSS classes. * * @param array $css_class The current CSS classes. Array of strings. * @param WP_Post $page The current page … Read more