|
|
@@ -195,6 +195,32 @@ function dw_search_excerpt_highlight( $block_content, $block, $instance ) {
|
|
|
);
|
|
|
}
|
|
|
add_filter( 'render_block_core/post-excerpt', 'dw_search_excerpt_highlight', 10, 3 );
|
|
|
+
|
|
|
+/**
|
|
|
+ * Sticky posts on a custom Query Loop block (inherit:false — e.g. /desk/posts) get
|
|
|
+ * prepended to EVERY page, not just the first, because the block query never sets
|
|
|
+ * ignore_sticky_posts. Pin them to page 1 only: on later pages, stop prepending and
|
|
|
+ * drop the stickies (already shown up top on page 1). The inherit:true search/archive
|
|
|
+ * blocks handle stickies via the main query, so leave those alone.
|
|
|
+ */
|
|
|
+function dw_query_loop_sticky_first_page_only( $query, $block ) {
|
|
|
+ if ( ! empty( $block->context['query']['inherit'] ) ) {
|
|
|
+ return $query;
|
|
|
+ }
|
|
|
+ $query_id = isset( $block->context['queryId'] ) ? $block->context['queryId'] : 0;
|
|
|
+ $key = 'query-' . $query_id . '-page';
|
|
|
+ $page = empty( $_GET[ $key ] ) ? 1 : absint( $_GET[ $key ] );
|
|
|
+ if ( $page > 1 ) {
|
|
|
+ $sticky = get_option( 'sticky_posts' );
|
|
|
+ if ( ! empty( $sticky ) ) {
|
|
|
+ $query['post__not_in'] = array_merge( isset( $query['post__not_in'] ) ? $query['post__not_in'] : array(), $sticky );
|
|
|
+ }
|
|
|
+ $query['ignore_sticky_posts'] = 1;
|
|
|
+ }
|
|
|
+ return $query;
|
|
|
+}
|
|
|
+add_filter( 'query_loop_block_query_vars', 'dw_query_loop_sticky_first_page_only', 10, 2 );
|
|
|
+
|
|
|
function dw_scripts() {
|
|
|
global $post;
|
|
|
wp_enqueue_style( 'style-min', get_template_directory_uri() . '/v4-style.min.css', array(), filemtime( get_template_directory() . '/v4-style.min.css' ) );
|