/**
* Plugin Name: Atlas Customizations
* Description: Do not remove please! This plugin includes site-specific functions. If you have it installed, inspect it's code before deactivation.
* Author: Portnov Internet Agency
* Author URL: https://portnov.agency/
* Version: 1.0.0
*/
define( 'PLUGIN_DIR', dirname( __FILE__ ) );
require_once PLUGIN_DIR . '/assets/index.php';
require_once PLUGIN_DIR . '/shortcodes.php';
add_filter( 'get_the_archive_title', function ( $title ) {
if( is_home() ) {
$title = __('Actualités','atlas');
}
return $title;
});
/**
* Do not show sticky
*/
function remove_sticky_from_main_loop( $query ) {
if( is_home() && $query->is_main_query() && ! is_admin() ) {
$query->set( 'ignore_sticky_posts', true );
$query->set( 'post__not_in', get_option('sticky_posts') );
}
}
add_action( 'pre_get_posts', 'remove_sticky_from_main_loop' );
/**
* AJAX load more, following this tutorial - https://rudrastyh.com/wordpress/load-more-posts-ajax.html
*/
function atlas_loadmore_ajax_handler(){
// prepare our arguments for the query
$args = json_decode( stripslashes( $_POST['query'] ), true );
$args['paged'] = $_POST['page'] + 1; // we need next page to be loaded
$args['post_status'] = 'publish';
// it is always better to use WP_Query but not here
query_posts( $args );
if( have_posts() ) :
// run the loop
while( have_posts() ): the_post();
?>