Last active
July 4, 2023 17:04
-
-
Save devuri/65ff608508c1127c95f03d37fcbc2242 to your computer and use it in GitHub Desktop.
Revisions
-
devuri revised this gist
Jul 4, 2023 . 1 changed file with 25 additions and 32 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,49 +1,42 @@ <?php /* Plugin Name: Most Recent Posts Description: Lists posts based on categories and limits the number of returns */ function most_recent_posts_shortcode($atts) { $a = shortcode_atts( array( 'postnumber' => 3, 'category' => 0, ), $atts ); ob_start(); $devuri_recent_posts = wp_get_recent_posts(array( 'numberposts' => $a['postnumber'], 'category' => $a['category'], 'post_status' => 'publish', )); foreach ($devuri_recent_posts as $devuri_recent) { echo '<div class="mrp-wrapper" style="padding: 2px;">'; echo '<ul class="mrp-ul" style="padding: 8px; overflow: hidden; border-top: solid thin beige;"><li>'; echo '<div class="mrp-featimage" style="padding-right: 12px;">'; echo '<a href="' . get_permalink($devuri_recent['ID']) . '"> ' . get_the_post_thumbnail($devuri_recent['ID'], 'medium') . '</a>'; echo '</div>'; echo ' <strong><a href="' . get_permalink($devuri_recent['ID']) . '"> ' . $devuri_recent['post_title'] . '</a></strong>'; echo '<br/>' . date('jS F, Y', strtotime($devuri_recent['post_date'])); echo '</li></ul>'; echo '</div>'; } wp_reset_query(); $output_mrp_obj = ob_get_contents(); ob_end_clean(); return $output_mrp_obj; } add_shortcode('most_recent_post', 'most_recent_posts_shortcode'); -
devuri revised this gist
Jul 4, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ /** * list post based on categories and limit number of returns *******************************************************************/ add_shortcode("most_recent_post", function ($atts) { $a = shortcode_atts( [ -
devuri created this gist
Jul 4, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ <?php /** * list post based on categories and limit number of returns *******************************************************************/ add_shortcode("most_recent_post", function mrp_shrtfunc($atts) { $a = shortcode_atts( [ "postnumber" => 3, "category" => 0, ], $atts ); ob_start(); // php only $devuri_recent_posts = wp_get_recent_posts([ "numberposts" => $a["postnumber"], "category" => $a["category"], "post_status" => "publish", ]); foreach ($devuri_recent_posts as $devuri_recent) { echo '<div class="mrp-wrapper" style="padding: 2px;">'; echo '<ul class="mrp-ul" style="padding: 8px; overflow: hidden; border-top: solid thin beige;"><li>'; echo '<div class="mrp-featimage" style="padding-right: 12px;">'; echo '<a href="' . get_permalink($devuri_recent["ID"]) . ' "> ' . get_the_post_thumbnail($devuri_recent["ID"], "medium") . "</a>"; echo "</div>"; //echo '<strong><a href="'. get_permalink($devuri_recent["ID"]) . ' "> ' . $a['postimage']. '</a>' ; echo ' <strong><a href="' . get_permalink($devuri_recent["ID"]) . ' "> ' . $devuri_recent[post_title] . "</a></strong>"; echo "<br/>" . date("jS F, Y", strtotime($devuri_recent[post_date])); echo "</li></ul>"; echo "</div>"; } wp_reset_query(); $output_mrp_obj = ob_get_contents(); ob_end_clean(); return $output_mrp_obj; });