Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/taxonomy/index.js.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions build/taxonomy/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

$taxonomy = get_taxonomy( $attributes['taxonomy'] );

if ( $block->context['query']['inherit'] ) {
$query_var = sprintf( 'query-%s', $attributes['taxonomy'] );
$page_var = 'page';
$base_url = str_replace( '/page/' . get_query_var( 'paged' ), '', remove_query_arg( [ $query_var, $page_var ] ) );
} else {
if ( empty( $block->context['query']['inherit'] ) ) {
$query_id = $block->context['queryId'] ?? 0;
$query_var = sprintf( 'query-%d-%s', $query_id, $attributes['taxonomy'] );
$page_var = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
$base_url = remove_query_arg( [ $query_var, $page_var ] );
} else {
$query_var = sprintf( 'query-%s', $attributes['taxonomy'] );
$page_var = 'page';
$base_url = str_replace( '/page/' . get_query_var( 'paged' ), '', remove_query_arg( [ $query_var, $page_var ] ) );
}
Comment on lines -10 to 19
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is appears to just be flipping the logic around and not actually changing anything, was it solving something specific?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roborourke Yeah, not sure what that is :)

Looks like removing pagination while doing the search should happen in view.js.


$terms = get_terms( [
Expand Down
2 changes: 1 addition & 1 deletion build/taxonomy/view.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('@wordpress/interactivity', array('id' => '@wordpress/interactivity-router', 'import' => 'dynamic')), 'version' => 'e7ba522c0e73d74a56f1', 'type' => 'module');
<?php return array('dependencies' => array('@wordpress/interactivity', array('id' => '@wordpress/interactivity-router', 'import' => 'dynamic')), 'version' => '345fefaef4946b1f7924', 'type' => 'module');
2 changes: 1 addition & 1 deletion build/taxonomy/view.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/taxonomy/view.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/taxonomy/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ const updateURL = async ( action, value, name ) => {
} else {
url.searchParams.delete( name );
}

// Remove pagination when performing a search
// for your specific pagination format: query-{id}-page
const searchParams = url.searchParams;
[...searchParams.keys()].forEach(param => {
if (param.match(/query-\d+-page/) || param === 'paged') {
searchParams.delete(param);
}
});
Comment on lines +11 to +18
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be possible to scope this to the current query loop block as this will reset pagination for all query loops on the page, and they should be able to work independently. E.g. if name === 's' remove the paged param, if name !== 's', remove name.replace( '-s', '-page' ).


const { actions } = await import( '@wordpress/interactivity-router' );
await actions.navigate( url.toString() );
};
Expand Down