WP Tiles
[resolved] Pages + Most recent post (2 posts)

  1. gonzagarg
    Posted 1 year ago #

    I am using the shortcode from http://wordpress.org/support/topic/manual-order-1?replies=2 with post_type set to "any" to add some specific pages and posts in a particular order:

    [wp-tiles posts_query='include=241,344,346,247,349&orderby=post__in&post_type=any' template='Alternative']

    Is there a way to specify the most recent post into this sequence so that I can have certain pages, certain posts and the most recent post?

    Thanks so much for making this plugin available.


  2. Mike Martel
    Plugin Author

    Posted 1 year ago #


    The easiest way (well..) to achieve this effect is with the gist you asked about in your other post: set the posts/pages up in their set places and let WP Tiles automatically come up with that last tile, that contains the most recent post.

    Alternatively, you could add a function to wp-tiles-data, that adds another tile to the tile array. Something like:

    add_filter( 'wp-tiles-data',function( $data ) {
        $posts = get_posts( array(
            'numberposts' => 1
            // Posts query goes here
        ) );
        $post = reset( $posts );
        $hideByline = apply_filters( 'wp-tiles-hide-byline', $hideByline, $post->ID, $post );
        $categories = wp_get_post_categories( $post->ID, array( "fields" => "all" ) );
        $category_slugs = $category_names = array();
        foreach( $categories as $category ) {
            $category_slugs[] = $category->slug;
            $category_names[] = $category->name;
        $data[] = array(
            "id"          => $post->ID,
            "title"       => apply_filters( 'the_title', $post->post_title ),
            "url"         => get_permalink( $post->ID ),
            "byline"      => $byline,
            "img"         => wp_tiles()->get_first_image( $post ),
            "color"       => $color,
            "bylineColor" => 'rgba(0,0,0,0.7)', // Your colour goes here
            "hideByline"  => false, // or true..
            "categories"  => $category_slugs
        return $data;
    } );

    Mind you: untested code!!

    Good luck!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Tiles
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.