Hello,
I am using the Minimalistix theme on my self-hosted www.ads-software.com website, and I’m experiencing an issue with category archives.
Issue:
When I assign a post to only one category, it still appears in multiple category archives. For example, if I assign a post to “Lifestyle,” it also appears in “Travel” even though “Travel” is not selected.
What I’ve Tried:
? Checked post settings to confirm that only one category is assigned.
? Verified that “Travel” is not set as a parent category of “Lifestyle.”
? Checked the default post category setting in Settings > Writing to make sure it isn’t overriding the assignment.
? Created a test post to confirm the issue persists.
? Inspected the Query Loop in the “All Archives” template but couldn’t find an option to fix it.
Request:
I would appreciate guidance on whether this is a theme-related issue or if there is a setting in the Query Loop block that needs adjustment.
Thank you for your time and support!
Best regards,
Polo
]]>But I can’t figure out what this means: “set the dynamic data to Post Meta, and in the post meta field just type in the name of your custom field.”
Where do I set these things? Also I can’t find any “Post Meta” field in the UI. I would be very thankful for your help.
]]>Right now it displays the sample post as:
February 21, 2025
Uncategorized
The formatting I’d prefer is:
February 21, 2025 | Posted in: Uncategorized
How do I accomplish this? I can’t seem to figure out a way to get the two items (Date & Categories) on the same line. Any suggestions would be appreciated. Thank you.
]]>Right now it displays the sample post as:
February 21, 2025
Uncategorized
The formatting I’d prefer is:
February 21, 2025 | Posted in: Uncategorized
How do I accomplish this? I can’t seem to figure out a way to get the two items (Date & Categories) on the same line. Any suggestions would be appreciated. Thank you.
]]>However, in the editor, there is a hidden copy of the first post, what breaks my grid layout. This only happens in the editor, not in the frontend, but it is very annoying. Is this strange behavior normal in the query loop block? Is there a fix or something I can do to remove the hidden copy?
]]>I’m redesigning my website, originally created with a classic theme and a popular website builder, using only the block editor and twenty twenty-four theme. The learning curve has been steep, so I’m likely missing something here…
I’m using the query loop to display posts. I’ve played around with pretty much all patterns and am confused with the following: grid and offset patterns (ie, patterns displaying the posts in multiple columns) only seem to support pagination per post template, rather than per pattern. Take a look at these setups:
Because there are two query loops per column here, there are also two post templates and hence two pagination blocks (!). My desired behavior would be one pagination block per pattern.
I also noticed that the pagination URLs of grid patterns in general result in ugly URLs such as: /?query-321-page=2 , /?query-321-page=3, /?query-322-page=2, etc. One column patterns result in familiar pagination URLs such as /page/2/, /page/3/, etc.
I read the documentation, namely:
A Pagination block is included by default if you choose a correct pattern in a Query Loop block. That said, you can also insert it manually when needed.
What is a “correct pattern”? How can I manually insert the pagination block for grid and offset patterns?
What about the pagination URLs – is there a workaround here?
]]>I am trying to add categories / Product categories to Query Loop block as a post type (Not a filter!). Idea is to output them according to a customisable query template with image and text. and then add filter = Parent, so that a category parent ca be set to select which cats to show.
I did some hacking together with Chat and I do not seem to get any further. Same fixes back and forth. Are there any ideas on how to accomplish this.
Alpha Code or lower:
// 1. Register Product Categories as a Custom Post Type for Query Block
function register_product_cat_as_post_type() {
// Get the custom product category base slug from WooCommerce settings
$product_cat_base = get_option( 'woocommerce_product_cat_base', 'product-category' );
// Register product categories as a custom post type for the query block
register_post_type( 'product_cat', array(
'label' => __( 'Product Categories', 'woocommerce' ),
'public' => true,
'show_in_rest' => true,
'rest_base' => 'product_cat',
'show_in_graphql' => true,
'supports' => array( 'title', 'thumbnail' ),
'has_archive' => false,
'show_ui' => true,
'hierarchical' => true,
'rewrite' => array( 'slug' => $product_cat_base ), // Dynamically set the slug based on WooCommerce permalink settings
) );
}
add_action( 'init', 'register_product_cat_as_post_type' );
// 2. Add Product Categories to the Query Block filters
function add_product_categories_to_query_block( $settings ) {
if ( isset( $settings['core/query'] ) ) {
// Add product categories as a filterable taxonomy in the query block
$settings['core/query']['supports']['filters'] = array(
'taxonomy' => array(
'product_cat' => __( 'Product Categories', 'woocommerce' ),
),
);
}
return $settings;
}
add_filter( 'block_editor_settings_all', 'add_product_categories_to_query_block' );
// 3. Modify the Parent Category Filter to Autofill Product Categories
function autofill_parent_category_filter( $filters, $block_instance ) {
if ( isset( $filters['product_cat'] ) ) {
// Check WooCommerce setting to hide empty categories (based on stock setting)
$hide_empty = get_option( 'woocommerce_hide_out_of_stock_items', 'no' ) === 'yes';
// Check if the "Category Order and Taxonomy Terms Order" plugin is active
$is_category_order_plugin_active = is_plugin_active( 'taxonomy-terms-order/taxonomy-terms-order.php' );
error_log('Is "Category Order and Taxonomy Terms Order" plugin active? ' . ($is_category_order_plugin_active ? 'Yes' : 'No'));
// Get the top-level categories and order conditionally, and hide empty categories
if ( $is_category_order_plugin_active ) {
// If plugin is active, order by term_order (Category Order and Taxonomy Terms Order plugin)
$categories = get_terms( array(
'taxonomy' => 'product_cat',
'parent' => 0, // Only top-level categories
'orderby' => 'term_order', // Use term_order set by Taxonomy Terms Order plugin
'order' => 'ASC', // Ascending order
'hide_empty' => $hide_empty, // Dynamically set based on WooCommerce setting
) );
} else {
// Fallback to WooCommerce menu_order or name ordering if the plugin is not active
$categories = get_terms( array(
'taxonomy' => 'product_cat',
'parent' => 0, // Only top-level categories
'orderby' => 'menu_order', // First, try ordering by menu_order
'order' => 'ASC', // Ascending order
'hide_empty' => $hide_empty, // Dynamically set based on WooCommerce setting
) );
// If no categories are ordered manually, fallback to ordering by name
if ( empty( $categories ) || is_wp_error( $categories ) ) {
$categories = get_terms( array(
'taxonomy' => 'product_cat',
'parent' => 0,
'orderby' => 'name', // Fallback to ordering by name
'order' => 'ASC',
'hide_empty' => $hide_empty, // Dynamically set based on WooCommerce setting
) );
}
}
// Log the categories fetched
error_log('Fetched categories: ' . print_r($categories, true));
// Prepare options if categories were fetched successfully
if ( !is_wp_error( $categories ) && !empty( $categories ) ) {
$options = array();
foreach ( $categories as $category ) {
$options[] = array(
'label' => $category->name, // Display the category name
'value' => $category->term_id, // Use the category ID for filtering
);
}
// Update the filter options in the block instance
if ( isset( $filters['product_cat'] ) ) {
$filters['product_cat']['options'] = $options;
} else {
error_log('No categories found or error with get_terms');
}
}
}
return $filters;
}
add_filter( 'block_editor_settings_all', 'autofill_parent_category_filter', 10, 2 );
// 4. Handle the Query and Output for Product Categories
function product_category_query_and_output( $query_args, $block_instance ) {
// Ensure we're dealing with product categories
if ( isset( $block_instance['post_type'] ) && $block_instance['post_type'] === 'product_cat' ) {
// Get filters if available
$filters = isset( $block_instance['filters'] ) ? $block_instance['filters'] : [];
// Set default hide_empty to match WooCommerce's setting for out-of-stock items
$hide_empty = get_option( 'woocommerce_hide_out_of_stock_items', 'no' ) === 'yes';
// Set the default query args for product categories
$query_args['taxonomy'] = 'product_cat'; // Query for product categories
$query_args['orderby'] = 'menu_order'; // Try ordering by manual (menu_order)
$query_args['order'] = 'ASC'; // Ascending order
$query_args['hide_empty'] = $hide_empty; // Hide empty categories (optional)
// Fallback: if manual ordering is not set, use alphabetical order
if ( empty( $query_args['orderby'] ) || !in_array( $query_args['orderby'], ['name', 'menu_order'] ) ) {
$query_args['orderby'] = 'name';
}
// Handle parent category filter (if set)
if ( !empty( $filters['product_cat'] ) ) {
$parent_category = (int) $filters['product_cat'];
$query_args['tax_query'] = array(
array(
'taxonomy' => 'product_cat',
'field' => 'id',
'terms' => $parent_category,
'operator' => 'IN',
),
);
}
// Set the number of categories to show
$query_args['posts_per_page'] = isset($block_instance['number']) ? $block_instance['number'] : -1; // Show all by default
}
Wishes:
I have messed with this for a long time, and I am not super skilled with PHP, so all help is very appreciated.
In my case, I fire this from a child theme in a sub functions.php with dependencies of Woo.
Thx
]]>I’m redesigning my website, originally created with a classic theme and a popular website builder, using only the block editor and twenty twenty-four theme. The learning curve has been steep, so I’m likely missing something here…
I’m using the query loop to display posts. I’ve played around with pretty much all patterns and am confused with the following: grid and offset patterns (ie, patterns displaying the posts in multiple columns) only seem to support pagination per post template, rather than per pattern. Take a look at these setups:
Because there are two query loops per column here, there are also two post templates and hence two pagination blocks (!). My desired behavior would be one pagination block per pattern.
I also noticed that the pagination URLs of grid patterns in general result in ugly URLs such as: /?query-321-page=2 , /?query-321-page=3, /?query-322-page=2, etc. One column patterns result in familiar pagination URLs such as /page/2/, /page/3/, etc.
I read the documentation, namely:
A?Pagination?block is included by default if you choose a correct pattern in a Query Loop block. That said, you can also insert it manually when needed.
What is a “correct pattern”? How can I manually insert the pagination block for grid and offset patterns?
What about the pagination URLs – is there a workaround here?
]]>function filter_specific_query_loop($query) {
// Check if this is an admin query or not the main query
if (is_admin() || !$query->is_main_query()) {
return;
}
// Check for the presence of the custom query parameter
if (isset($query->query_vars['custom_query_loop']) && $query->query_vars['custom_query_loop']) {
// Modify the query to include multiple post types
$query->set('post_type', array('post', 'restaurants', 'activities', 'equipment','recipes'));
}
}
add_action('pre_get_posts', 'filter_specific_query_loop');
// Add a filter to include the custom query parameter when rendering the block
function add_custom_query_var($block_content, $block) {
if ($block['blockName'] === 'core/query') {
if (isset($block['attrs']['className']) && strpos($block['attrs']['className'], 'custom-query-loop') !== false) {
add_filter('query_vars', function ($query_vars) {
$query_vars[] = 'custom_query_loop';
return $query_vars;
});
}
}
return $block_content;
}
add_filter('render_block', 'add_custom_query_var', 10, 2);
I added custom class name: custom-query-loop to the query loop (located on home page). When I preview my page however, I only see one post type from the query loop.
Am I doing something wrong? My site is not live yet.
Thank you in advance for help!
]]>