• In my installation, I use this shortcode but I wanted to set it up so that instead of having to specify the ID of a post, I wanted it to automatically show the last post unless one was specified. I did the following in function __construct():

    1) Add $wpdb to the global declaration
    2) Add the following line before the declaration of $this->defaults:
    $last_post_id = $wpdb->get_var( $wpdb->prepare( “SELECT MAX(ID) FROM {$wpdb->posts} WHERE post_type=’post’ and post_status=’publish’ LIMIT 1”);
    3) In $this->defaults, set the default ‘id’ to $last_post_id

    Can I suggest that this idea be incorporated into the shortcode either as a default or as an option that could be set?

    http://ww.wp.xz.cn/plugins/post-content-shortcodes/

Viewing 1 replies (of 1 total)
  • Plugin Author Curtiss Grymala

    (@cgrymala)

    Try using the post-list shortcode instead and see if that makes things any easier. The two shortcodes have most of the same options now, so you should be able to get almost the same output without having to change any code anywhere. Instead, you would just use something like:

    [post-list post_type="post" orderby="date" order="desc" numberposts=1 show_title=1 show_content=1]

    There may be other options you want to include in the shortcode, too, but that should at least get you started.

Viewing 1 replies (of 1 total)

The topic ‘Display last post as default’ is closed to new replies.