From 21b289cbcd98e0fe4757eb5a942940c7ded687f5 Mon Sep 17 00:00:00 2001 From: Antoine Date: Mon, 13 Feb 2023 09:42:01 +0100 Subject: [PATCH] adding stuff in shortcut --- includes/shortcuts/shortcuts.php | 163 +++++++++++++++++++++---------- 1 file changed, 113 insertions(+), 50 deletions(-) diff --git a/includes/shortcuts/shortcuts.php b/includes/shortcuts/shortcuts.php index da3f5e4..54cf12a 100644 --- a/includes/shortcuts/shortcuts.php +++ b/includes/shortcuts/shortcuts.php @@ -1,24 +1,22 @@ + // ##### Syntax - -

- + +

+ - -

- + +

+ @@ -27,11 +25,13 @@ define( 'WP_DEBUG_DISPLAY', false ); // ##### Template parts 🡒 Get templates parts - get_template_part( 'template-parts/blocks/the-file', null, - array( - 'ID'=>$my_post_id, - ) - ); +get_template_part( + 'template-parts/blocks/the-file', + null, + array( + 'ID' => $my_post_id, + ) +); /** ------------------------------ QUERIES @@ -51,40 +51,40 @@ $posts = get_posts($args); // ##### Query 🡒 Recent posts $posts = wp_get_recent_posts([ - 'numberposts' => 4 , + 'numberposts' => 4, 'post_status' => 'publish' ]); // ##### Query 🡒 With Metaqueries $args = array( - 'post_type'=>'activities', - 'post_status' => array( 'publish', 'future' ), + 'post_type' => 'activities', + 'post_status' => array('publish', 'future'), 'numberposts' => '3', 'meta_key' => 'date', 'orderby' => 'meta_value', 'order' => 'ASC', // ######## Main 'meta_query' => array( - array( - 'key' => 'date', - 'value' => $today, - 'compare' => '>=' - ) + array( + 'key' => 'date', + 'value' => $today, + 'compare' => '>=' ) + ) ); $recent_activites = wp_get_recent_posts($args); // ##### Query 🡒 Wordpress Global Query Loop -$args = array('posts_per_page' => 6,'post_type' => 'post'); -$the_query = new WP_Query( $args ); +$args = array('posts_per_page' => 6, 'post_type' => 'post'); +$the_query = new WP_Query($args); -if ( $the_query->have_posts() ) { +if ($the_query->have_posts()) { echo '