* Author: Nick van de Veerdonk * Author URI: https://jaaadesign.nl/ */ // create custom plugin settings menu add_action('admin_menu', 'amp_recent_posts_menu'); function amp_recent_posts_menu() { //create new top-level menu add_menu_page('AMP Recent Posts Settings', 'AMP Recent Posts', 'administrator', __FILE__, 'amp_recent_posts_options_page' , plugins_url('/images/icon.png', __FILE__), 102 ); //call register settings function add_action( 'admin_init', 'register_amp_recent_posts_settings' ); } function register_amp_recent_posts_settings() { //register our settings register_setting( 'amp_recent_posts_group', 'use_hook' ); register_setting( 'amp_recent_posts_group', 'set_prio_hook_amp' ); register_setting( 'amp_recent_posts_group', 'append_amp' ); register_setting( 'amp_recent_posts_group', 'heading_amp' ); register_setting( 'amp_recent_posts_group', 'max_amp' ); register_setting( 'amp_recent_posts_group', 'type_check_post_amp' ); register_setting( 'amp_recent_posts_group', 'cust_post_supp_amp' ); register_setting( 'amp_recent_posts_group', 'exclude_any_id_amp_1' ); register_setting( 'amp_recent_posts_group', 'exclude_any_id_amp_2' ); register_setting( 'amp_recent_posts_group', 'exclude_any_id_amp_3' ); register_setting( 'amp_recent_posts_group', 'exclude_any_id_amp_4' ); register_setting( 'amp_recent_posts_group', 'exclude_any_id_amp_5' ); register_setting( 'amp_recent_posts_group', 'sel_thumb_amp' ); register_setting( 'amp_recent_posts_group', 'sel_date_amp' ); } function amp_recent_posts_options_page() { ?>

AMP Recent Posts



AMP Recent Posts Settings

Use hook? />

This will implement the recent posts without shortcode, both can be used together.

Priority of hook

Default: 3 to play nice with our other plugins, if you wish to move the recent posts up of down change this number.

Set endpoint*

Default: 'amp', the endpoint is the last part of the URL, AMP plugin by Automattic uses 'amp'

Heading

Add an <H3> heading here.

Set number of posts*

Default is a maximum of 5.

Return posts? " />

Check this to show recent posts, as opposed to -for example- 'pages'.

Other post types

If you wish to return a different post type set it here. (ex.: post, page, product, portfolio).

Display featured image? " />

Check this to show featured images.

Show date? " />

Check this to show the dates.

Exclude posts by ID

Some posts are more equal than others, you can find their ID in the admin URL of the post, page etc.




★★★★★ If you like this plugin please consider rating it, thank you!


 
AMP Recent Posts

Our other plugins

Articles

Keep in touch

array( $type1, $type2 ), 'order' => 'DESC', 'orderby' => 'date', 'showposts' => $maxamp, 'post__not_in' => array (get_the_ID(), $numm1, $numm2, $numm3, $numm4, $numm5 ), 'post_status' => 'publish', ); $attappendamp = get_option( 'append_amp' ); $attheadingamp = get_option( 'heading_amp' ); $ampthumb = get_the_post_thumbnail( 'thumbnail' ); echo '
'; echo '
'; echo '
'; echo '

'.$attheadingamp.'

'; echo '
    '; // The Query $query = new WP_Query( $args ); // The Loop if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); // do something $ampthumb = get_the_post_thumbnail_url(); $ampthumbalt = get_the_title(); $ampdefimg = plugin_dir_url( __FILE__ ) . 'images/default-thumb.jpg'; $ampdate = get_the_date(); // Featured image + has thumb + date if ( get_option( 'sel_thumb_amp' ) == '1' && has_post_thumbnail() && get_option( 'sel_date_amp' ) == '1') { echo '
  • '.get_the_title().'

    '. $ampdate .'

  • '; } // Featured image + has thumb else if ( get_option( 'sel_thumb_amp' ) == '1' && has_post_thumbnail() && !get_option( 'sel_date_amp' ) == '1') { echo '
  • '; } // Featured image + NO thumb + date else if ( get_option( 'sel_thumb_amp' ) == '1' && !has_post_thumbnail() && get_option( 'sel_date_amp' ) == '1') { echo '
  • '.get_the_title().'

    '. $ampdate .'

  • '; } // Featured image + NO thumb + NO date else if ( get_option( 'sel_thumb_amp' ) == '1' && !has_post_thumbnail() && !get_option( 'sel_date_amp' ) == '1') { echo '
  • '; } // NO featured image + date else if ( !get_option( 'sel_thumb_amp' ) == '1' && get_option( 'sel_date_amp' ) == '1' ) { echo '
  • '.get_the_title().'

    '. $ampdate .'

  • '; } // NO featured image + NO date else if ( !get_option( 'sel_thumb_amp' ) == '1' && !get_option( 'sel_date_amp' ) == '1' ) { echo '
  • '; } } } else { echo '

    No recent posts found

    '; } echo '
'; echo '
'; echo '
'; echo '
'; // Restore original Post Data wp_reset_postdata(); } } // Shortcode function amp_recent_function($atts, $append, $heading) { extract(shortcode_atts(array( 'append' => 'amp', 'heading' => null, 'max' => 10, 'cpt1' => null, 'cpt2' => null, 'cpt3' => null, ), $atts)); $return_string = '