Add ignore_sticky param to blog shortcode

This commit is contained in:
Tetrakern 2023-09-11 12:26:34 +02:00
parent a1b3614506
commit c241a3a915
2 changed files with 6 additions and 3 deletions

View File

@ -389,6 +389,7 @@ The custom HTML block is the best way to add special elements to the content, su
Renders paginated blog posts akin to the default blog page, but with options. Makes use of the main query pagination variable, so only use this once per page. Optional parameters are **per_page**, **author**, **exclude_cat_ids**, **exclude_tag_ids**, **categories**, **tags**, **rel**, and **class**.
* **per_page:** Number of posts per page. Defaults to theme settings.
* **ignore_sticky:** Whether sticky posts should be ignored or not. Default `false`.
* **author:** Only show posts of a specific author. Make sure to write the name right.
* **author_ids:** Only show posts of a comma-separated list of author IDs.
* **exclude_author_ids:** Comma-separated list of author IDs to exclude.

View File

@ -956,7 +956,7 @@ function fictioneer_shortcode_chapter_list( $attr ) {
</button>
<?php endif; ?>
<ol class="chapter-group__list">
<li class="chapter-group__list-item _empty"><?php _e( 'No chapters published yet.', 'fictioneer' ) ?></li>
<li class="chapter-group__list-item _empty"><?php _e( 'No chapters published yet.', 'fictioneer' ); ?></li>
</ol>
</div>
<?php // <--- End HTML
@ -1352,6 +1352,7 @@ function fictioneer_shortcode_blog( $attr ) {
$exclude_cat_ids = fictioneer_explode_list( $attr['exclude_cat_ids'] ?? '' );
$exclude_author_ids = fictioneer_explode_list( $attr['exclude_author_ids'] ?? '' );
$author_ids = fictioneer_explode_list( $attr['author_ids'] ?? '' );
$ignore_sticky = filter_var( $attr['ignore_sticky'] ?? 0, FILTER_VALIDATE_BOOLEAN );
$rel = 'AND';
$classes = '';
@ -1365,7 +1366,8 @@ function fictioneer_shortcode_blog( $attr ) {
'post_type' => 'post',
'post_status' => 'publish',
'paged' => max( 1, $page ),
'posts_per_page' => $attr['per_page'] ?? get_option( 'posts_per_page' )
'posts_per_page' => $attr['per_page'] ?? get_option( 'posts_per_page' ),
'ignore_sticky_posts' => $ignore_sticky
);
// Author?
@ -1459,7 +1461,7 @@ function fictioneer_shortcode_blog( $attr ) {
} else {
// Start HTML ---> ?>
<article class="post _empty">
<span><?php _e( 'No (more) posts found.', 'fictioneer' ) ?></span>
<span><?php _e( 'No (more) posts found.', 'fictioneer' ); ?></span>
</article>
<?php // <--- End HTML
}