Can’t display posts by filtering categories using isotope.js

Can you try: <?php if (have_posts()): ?> <?php while (have_posts()): the_post(); ?> <?php $categories = get_the_category(); $listCategories = []; foreach ($categories as $category) { $listCategories[] = $category->slug; } ?> <!– Isotope Grid-Item –> <div class=”col-md-3 col-sm-4 col-xs-12 isotope-grid-item <?php echo implode(‘ ‘, $listCategories); ?>” data-category=”<?php echo implode(‘,’, $listCategories); ?>”> <div class=”isotope-item”> <a href=”#”> <div class=”isotope-feature-image”><?php … Read more

How to search through all child taxonomies using WP_Query?

Finally figured out the solution. Answering it if anyone finds it useful. Where $_GET[‘s_qr’] has a search query from a user from another page. $i = 0; $parent_name=””; $taxonomyName = “product-cat”; $search_r = array(); $parent_terms = get_terms( $taxonomyName, array( ‘parent’ => 0, ‘orderby’ => ‘slug’, ‘hide_empty’ => false ) ); foreach ( $parent_terms as $pterm … Read more

How can I see $post object in frontend from functions.php?

Adding: global $post; print_r ($post); alone, won’t work in functions.php (becuase WP’s core functions etc wouldn’t be loaded). It would inside a relevant template file, but not in functions.php. To make it work in functions.php, you need to do it inside an function that is hooked to an appropriate hook. The “appropriate” hook may depend … Read more

Can any IDE (eg PHPStorm, VS Code) correctly show functions added via require get_template_directory() string results?

In the process of looking this up I determined the correct answer is to use the full local path in my dev environment, and add a comment in the code like /** @define “get_template_directory()” “/home/myuser/mywpproject/wp-content/themes/mytheme” */ And this works for the subsequent references in that file in JetBrains IDE / PHPStorm immediately. Thanks to here … Read more