WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Pages Most recent post

[Resolved] Pages Most recent post

Viewing 1 replies (of 1 total)
  • Plugin Author Mike Martel

    @mike_cowobo

    Hi!

    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:

    <?php
    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!
    Mike

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Pages Most recent post’ is closed to new replies.