Skip to content

Commit a5224d3

Browse files
chore: address review for article limit
Co-authored-by: iftakharul-islam <88052038+iftakharul-islam@users.noreply.github.com>
1 parent a5173af commit a5224d3

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

templates/shortcode.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
foreach ( $main_doc['sections'] as $section ) {
3030
$article_args = array(
3131
'post_type' => 'docs',
32-
'posts_per_page' => ! empty( $article_limit ) && $article_limit > 0 ? $article_limit : '-1',
32+
'posts_per_page' => $article_limit > 0 ? $article_limit + 1 : '-1',
3333
'orderby' => 'menu_order',
34-
'order' => 'ASC'
34+
'order' => 'ASC',
3535
);
3636

3737
$article_args = apply_filters( 'wedocs_shortcode_page_section_args', $article_args );
@@ -40,9 +40,9 @@
4040

4141
$article_args = apply_filters( 'wedocs_shortcode_page_article_args', $article_args, $section );
4242

43-
$children_docs = get_children( $article_args );
44-
$total_children = count( $children_docs );
45-
$has_more_articles = ! empty( $article_limit ) && $article_limit > 0 && $total_children > $article_limit;
43+
$article_query = new \WP_Query( $article_args );
44+
$children_docs = $article_query->posts;
45+
$has_more_articles = $article_limit > 0 && count( $children_docs ) > $article_limit;
4646
if ( $has_more_articles ) {
4747
$children_docs = array_slice( $children_docs, 0, $article_limit );
4848
}
@@ -54,7 +54,7 @@
5454
$collapse_section_articles = wedocs_get_general_settings( 'collapse_articles', 'off' );
5555
?>
5656
<li>
57-
<a class='icon-view' href="<?php echo get_permalink( $section->ID ); ?>" target='_blank'>
57+
<a class='icon-view' href="<?php echo get_permalink( $section->ID ); ?>" target='_blank' rel='noopener noreferrer'>
5858
<?php echo esc_html( $post_title ); ?>
5959
</a>
6060
<?php if ( $children_docs ) : ?>
@@ -82,7 +82,7 @@ class='children has-icon <?php echo esc_attr( $collapse_section_articles !== 'on
8282
<?php endforeach; ?>
8383
<?php if ( $has_more_articles ) : ?>
8484
<li class="wedocs-view-all">
85-
<a href="<?php echo get_permalink( $section->ID ); ?>" target='_blank'>
85+
<a href="<?php echo get_permalink( $section->ID ); ?>" target='_blank' rel='noopener noreferrer'>
8686
<?php esc_html_e( 'View all', 'wedocs' ); ?>
8787
</a>
8888
</li>

0 commit comments

Comments
 (0)