SOLVED: Shortcode to display Divi project filtered by tag in WP Query loop

SOLUTION: I looked through Divi’s functions.php & saw that the term for the project tags is ‘project_tag’, so when I amended my $query args it now works! Thank you very much to everyone who responded 🙂 $query_args = array( ‘post_type’ => ‘project’, ‘post_status’ => ‘publish’, ‘order’ => ‘DESC’, ‘orderby’ => ‘date’, ‘posts_per_page’ => ‘3’, ‘project_tag’ … Read more

Create side bar widget showing list of years as hyperlinks for a custom post type

First, create the custom WordPress widget. This will query all the years that have at least one post for your custom post type “Meeting.” Save the following code in your theme’s functions.php file: class Meeting_Archive_Widget extends WP_Widget { public function __construct() { parent::__construct(‘meeting_archive’, ‘Meeting Archive’, array(‘description’ => ‘List Meetings by Year’)); } public function widget($args, … Read more

Different date time in results of search

All the date functions reference the global $post variable, but from your code the $post variable is not being used, so that’s why the date is wrong. Try this (untested): foreach ( $total_results as $tr ) { echo get_the_time( ‘j F Y, G:i’, $tr ); }

Global $post value outside the loop

Yes, this is how it is supposed to work. The global $post variable is set quite early in the page load, at the wp hook. As you can see from the hook order, this is before the loop starts. Basically the $post object exists independent from its actual content in the database, which you retrieve … Read more

Unexpected number of loops in while

This is because have_posts() is for the main loop, and not your custom query. Prefixing each use of have_posts() and the_post() with $WatchListQuery-> will fix it: if ( $WatchListQuery->have_posts() ) { while ( $WatchListQuery->have_posts() : $WatchListQuery->the_post();

get_the_ID() retrieves same ID on Gutenberg’s Query Loop

No, you did nothing wrong. It’s a known issue and in WordPress v6.1.3 and up to the current stable release as of writing (v6.2.2), it’s happening because of the following lines in get_the_block_template_html() which returns the markup for the current (block-based) template: $content = do_shortcode( $content ); $content = do_blocks( $content ); So as you … Read more

Using Query Loop Block to list all posts under each category

Use WP_Query directly in your WP theme template files instead of a block editor. // Define custom taxonomy (category) terms $categories = get_terms(array( ‘taxonomy’ => ‘your_custom_taxonomy’, // Change ‘your_custom_taxonomy’ to the name of your taxonomy ‘hide_empty’ => false, )); // Loop through each category foreach ($categories as $category) { echo ‘<h2>’ . $category->name . ‘</h2>’; … Read more