Support » Plugin: Metaphor Shortcodes » post block: show date, comments and categories (sort of wp theme entry-meta)

  • i see what you’re saying here about using hooks and filters.

    i wonder if i may get your help with this: i’m displaying blocks of posts in a grid, and i’ve added the code to the standard twentytwelve post footer with meta info like number of comments, publishing date, categories, etc.

    it works fine, but only for the first post block. the others show the same footer meta info (same comments number, same date, same categories). so obviously just adding the call to the twentytwelve function is not sufficient.

    is there any way i could get your post block function to output the meta info i’m after?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author metaphorcreations


    Could you show how you have your post block shortcode setup? You need to specific an “offset” attribute if you want to show anything except the latest post through the shortcode.

    Thread Starter maxgx


    thanks for the quick reply!

    i’m not targeting a specific category, but i pick and mix posts from any of them. i’m using this shortcode:

    [mtphr_post_block id="347" thumb_size="opening-thumb" excerpt_length="200" excerpt_more=""]

    well, i’m using more than one of these codes, each one within its own text widget, all inside a custom sidebar area, with css that displays the widgets according to their number.

    also i’d like the thumbnail image (the one above is a custom size) to be clickable using the same link as the title one.

    Thread Starter maxgx


    hey Joe, is there any problem with the code above? any hint on how i can solve it?

    Plugin Author metaphorcreations


    I don’t see anything wrong with the code above.

    If you’re using a filter to show custom content I wouldn’t suggest using the whole “remove_shortcode” option as show in the other thread. I would suggest using the following filter:

    function my_custom_post_block( $block, $excerpt, $args, $permalink=false ) {
      // Display your content however you'd like in here
      // Here's how you'd link a thumbnail
      if( $args['thumb_size'] != 'none' ) {
        echo '<a href="'.get_permalink().'">'.get_the_post_thumbnail( get_the_id(), $thumb_size ).'</a>';
    add_filter( 'mtphr_{post_type}_post_block', 'my_custom_post_block', 10, 3 );

    Where {post_type} is the name of the post type you want to filter. If you are just displaying normal posts, then use:

    add_filter( 'mtphr_post_post_block', 'my_custom_post_block', 10, 3 );

    I’m not sure what the twenty twelve footer meta looks like, but each post block should be setting the global $post object in order to use the wordpress functions “get_permalink”, get_the _id(), etc…

    If you paste the code you are using to display the meta I’ll take a look as well and see if there’s anything that looks wrong with it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘post block: show date, comments and categories (sort of wp theme entry-meta)’ is closed to new replies.