MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: machen (1008)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /disk001/machen/public_html/support/wp-content/themes/learnmore/inc/functions/get-posts.php
<?php
if ( ! function_exists( 'learnmore_get_posts' ) ) :
	/**
	 * Extends each array's object with associated posts
	 *
	 * @package LearnMore
	 */
	function learnmore_get_posts( $data = array() ) {
		foreach ( $data as $key=>$category ) {
			$args = learnmore_get_posts_args( $category );
			$all_posts = get_posts( $args );
			$data[$key]->posts = $all_posts;
		}
		return $data;
	}
endif;

if ( ! function_exists( 'learnmore_get_posts_args' ) ) :
	// Returns $args for 'get_categories' function based on user provided settings.
	function learnmore_get_posts_args( $category ) {
		$args = array(
			'orderby'    => get_theme_mod( 'kb_article_orderby', 'date' ),
			'order'      => get_theme_mod( 'kb_article_order', 'ASC' ),
			'numberposts' => get_theme_mod( 'kb_article_count', 5 ),
			'category'    => $category->term_id,
		);
		return $args;
	}
endif;