Site logo

Archived topic

Issue with Query Loop block on the front-end

21 replies · Started by Yerai on December 28, 2022

Viewing posts 1–15 of 22

Hello!

I'm currently using Generateblocks Query Loop block for link to posts or pages. It works nice in the site overall, but in custom category pages.

Category pages are built with wordpress pages, replacing the category page with a custom page with the same slug using a function that loads page template instead of category's.

Problem is the query loop grid breaks only in those category pages. In the backend everything seems fine, but in the frontend the structure changes.

Backend:

Frontend:

Is there a way to fix that?

Thank you in advance!

Hi Yerai,

If you're planning to override the default WordPress Archive pages with a Query Loop Block, you can use a Block Element - Loop Template.

Reference: https://docs.generateblocks.com/article/query-loop-overview/

If you prefer using a static page, can you provide the link where we can see the issue?

You may use the Private Information field for this: https://docs.generatepress.com/article/using-the-premium-support-forum/#private-information

Apologies for answering this late, these last days have been crazy for me.

Yeah, we are using static pages. I'll provide the url and credentials in the private info section.

Thank you in advance!

Here you have!

Thank you in advance.

Thank you. It seems some CSS is not loading.

As a first course of debugging, what we would recommend is to do #1 here: https://docs.generatepress.com/article/debugging-tips/

Can you try that and let us know how it goes?

It would be good to take a backup of your site before doing so.

I did all steps there, as the first one didn't have any effect.

The debug.log file didn't generate, and I didn't saw any error in the dashboard.

After that, I installed the query count plugin for debugging, I didn't see anything relevant.

So I moved to the next step.

After switching to TwentySeventeen theme, the issue fixed. And after switching back to GeneratePress, the page loaded correctly. A while after it showed up the issue again.

And finally, there is are no errors in the error_log file.

So I guess there is a weird issue that happens with GeneratePress, because GenerateBlocks loaded fine in the TwentySeventeen theme, but maybe I'm mistaken.

Thank you in advance.

Hi there,

what function are you using to swap the category archive to a static page ?

Hi David,

We are using this function:

function loadPageFirst() {
// get the actual category
$actualCategory = get_category( get_query_var('cat') );
// get the page with the same slug
$matchingPage = get_page_by_path( $actualCategory->slug );

// If no match, load the normal archive template and exit
if (!$matchingPage) {
include( get_template_directory() . '/archive.php');
die();
}

// Make a new query with the page's ID and load the page template
query_posts( 'page_id=' . $matchingPage->ID );
include( get_template_directory() . '/page.php');
die();
}
add_filter( 'category_template', 'loadPageFirst' );

Yes, all category pages are replaced by a static page. The method you provided works very well. There is no issue now! :)

Thank you David!

Awesome - glad to hear that!!

Hello again!

I've found an issue with the code of WPShowPosts.

In my site there is no more custom code than that one, but for some reason, posts pages are being replaced by the category page, as you can see here:

Category page:

Post page:

Curious thing is post's urls are untouched, which seems weird.

Is there a way to fix this?

Go to settings > permalinks, set . as the Category base.

Let me know if this works.

Sadly, it doesn't work :(

This archived topic is closed to new replies.