Viewing 6 replies - 1 through 6 (of 6 total)
  • OK, go to Dashboard>Plugins>Installed Plugins and click edit on Post Content Shortcodes.

    Edit this file: post-content-shortcodes/class-post-content-shortcodes.php

    Find this text:

    $this->defaults = apply_filters( 'post-content-shortcodes-defaults', array(
    				'id'			=> 0,
    				'post_type'		=> 'post',
    				'order'			=> 'asc',
    				'orderby'		=> 'post_title',
    				'numberposts'	=> -1,
    				'post_status'	=> 'publish',
    				'offset'		=> null,
    				'category'		=> null,
    				'include'		=> null,
    				'exclude'		=> null,
    				'meta_key'		=> null,
    				'meta_value'	=> null,
    				'post_mime_type'=> null,
    				'post_parent'	=> null,
    				/* Non-standard arguments */
    				'exclude_current'=> true,
    				'blog_id'		=> $blog_id,
    				'show_image'	=> false,
    				'show_excerpt'	=> false,
    				'excerpt_length'=> 0,
    				'image_width'	=> 0,
    				'image_height'	=> 0,
    				'show_title'    => false,
    				'show_author'   => true,
    				'show_date'     => true,
    				/* Added 0.3.3 */
    				'show_comments' => false,
    				'read_more' => false,
    				'shortcodes' => false,
    			) );

    And change show_date to true (as in the code above). For some reason these options aren’t available from the shortcode.

    Plugin Author Curtiss Grymala

    (@cgrymala)

    First of all, please don’t edit the actual plugin files. Those parameters are all passed through a filter, specifically so that you don’t have to edit the plugin file.

    Instead, use the following:

    add_filter( 'post-content-shortcodes-defaults', 'custom_pcs_show_date' );
    function custom_pcs_show_date( $defaults=array() ) {
        $defaults['show_date'] = true;
    }

    Secondly, if the show_date parameter is not working properly in the shortcode, that’s probably a bug that I’ll have to investigate. You should be able to just use:

    [post-content show_date=1]

    or

    [post-list show_date=1]

    Are you trying to use it in the post-content shortcode or the post-list shortcode? Are you using the latest version of the plugin? Thanks.

    I don’t know about OP, but it doesn’t work for me either. Trying to use it on post-list.

    Added filter to functions.php and this was outputted on the page:
    Warning: Invalid argument supplied for foreach() in …/wp-includes/shortcodes.php on line 297
    Additionally, the list could no longer find any posts to display… so, it broke, essentially.

    For what it’s worth, even editing the plugin file (as instructed above by Julian_Kingman didn’t work for me.

    Plugin Author Curtiss Grymala

    (@cgrymala)

    Whoops. I realized that I forgot to actually return the array in the function I included above. That code should look like the following, instead. Sorry about that:

    add_filter( 'post-content-shortcodes-defaults', 'custom_pcs_show_date' );
    function custom_pcs_show_date( $defaults=array() ) {
        $defaults['show_date'] = true;
        return $defaults;
    }

    Sorry, Curtiss. Your assistance is appreciated but this still just isn’t working.

    This is how it’s looking in my wysiwyg text:

    [post-list orderby=post_date order=desc numberposts=1 show_image=0 show_excerpt=1 excerpt_length=78 show_date=1 exclude_current=0 read_more=1]

    But no date is being printed.

    I’ve added:

    function custom_pcs_show_date( $defaults=array() ) {
        $defaults['show_date'] = true;
        return $defaults;
    
    }

    to functions.php and my short code looks like this: [post-list post_type="post" category=4 numberposts=5 show_date=1 show_excerpt=0 orderby="date" order="DESC"]

    I do not see the date? any tips

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Adding date of post’ is closed to new replies.