elementor / wp2static

WordPress static site generator for security, performance and cost benefits
https://wp2static.com
The Unlicense
1.43k stars 270 forks source link

Page crawl depth #275

Closed azdanov closed 5 years ago

azdanov commented 5 years ago

The issue is with crawling depth for blog and comment pages.

For example on a blog page blog/ there is a link to blog/page/2/ which works fine. But on blog/page/2/ there is a link to blog/page/3/ which is ignored during a crawl.

Same behavior happens with comments, e.g template-comments/#comments.

I know that it's possible to include a url manually, but it's not easy with pagination.

Is this a bug, or I'm missing some configuration?

leonstafford commented 5 years ago

@azdanov, which theme is this using? The plugin used to be more a traditional crawler, but now infers knowledge of URLs from WordPress for the first level and crawls one more level after that.

I'll look into the detection of the post/comment pagination URLs. We want to see them all in the initial crawl list preview on the Crawling tab

fmt commented 5 years ago

@azdanov meanwhile you could use something like:

function paginationHandler($query) {
  if(!is_admin() && $query->is_main_query()) {
    $offset = get_option('posts_per_page');
    if($query->is_paged) {
      $maxpostperpage = 1000;
      $postsperpage = $maxpostperpage - $offset;
      $query->set('posts_per_page', $postsperpage);
      $query->set('offset', $offset);
    } else {
      $query->set('posts_per_page', $offset);
    }
  }
  return;
}
add_action('pre_get_posts', 'paginationHandler');
azdanov commented 5 years ago

@leonstafford It's a custom theme based on Sage. Here is it's repo: azdanov/wordpress-first.

@fmt Thanks!

leonstafford commented 5 years ago

Thanks @azdanov, I'll use that to test.

leonstafford commented 5 years ago

I should have this working in first version tonight, with something like this in the FilesHelper class:

https://github.com/leonstafford/wp2static/issues/235#issuecomment-457904099

leonstafford commented 5 years ago

Remaining to fix in this issue:

azdanov commented 5 years ago

Remaining to fix in this issue

I've also noticed:

leonstafford commented 5 years ago

^ luckily, tags came for free with the category code (both taxonomy > term elements)

leonstafford commented 5 years ago

damn, one more:

Posts that split across multiple pages (will make new issue for that)

leonstafford commented 5 years ago

w00t, got it

/category/uncategorized/page/1
/my-lonely-post/comment-page-3
/my-oher-post/comment-page-3
/my-oher-post/comment-page-2
/my-lonely-post/comment-page-2
/my-lonely-post/comment-page-1
/my-oher-post/comment-page-1
azdanov commented 5 years ago

@leonstafford Good job!