• Resolved johnrobertsonsquid

    (@johnrobertsonsquid)


    Hello,

    I have 1 page(homepage) which has 8 tiles in it. I’ve been experimenting for months now (months!) but can’t get it to work. So here’s what I want to achieve:

    ? I would like that every tile is for every category. (e.g. 1st tile for category travel tips , 2nd tile for category destination and so on). So if I have a post for ‘travel tips’ only the travel tips tile will be changed and if I have a post for destination only the destination tile will be changed.

    P.S. Those are static tiles like they will just be in place and the only thing that’s gonna change is the post on the tile. Is it even possible?

    Kind Regards,
    John Robertson

    https://www.ads-software.com/plugins/wp-tiles/

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

    (@mike_cowobo)

    Hi John,

    This is not possible out of the box, but with some coding you could make it happen.

    All you need to do is get every post you want to display in an array and call the_wp_tiles with your posts as the first argument. Schematic example:

    $posts = array();
    $posts[] = get_post( FIRST_POST_FROM_CAT_X );
    $posts[] = get_post( FIRST_POST_FROM_CAT_Y );
    // ...
    
    the_wp_tiles( $posts );

    Kind regards,
    Mike

    Thread Starter johnrobertsonsquid

    (@johnrobertsonsquid)

    Hi Mike,

    I’m a newbie. I don’t know where to put that code. Please tell me where to put that code. and is ( FIRST_POST_FROM_CAT_X ) <- is this the latest post? and will the tiles be in the same place with that code? and the only thing that will change is it’s featured image(post)

    Sincerely,
    John Robertson

    Plugin Author Mike Martel

    (@mike_cowobo)

    Hi John, see my response to your other query to see how to proceed from here. Let me quickly explain the snippet a bit more:

    $posts = array();
    $posts[] = get_post( FIRST_POST_FROM_CAT_X );

    Here you must replace FIRST_POST_FROM_CAT_X with the actual ID of the post you want to display. So you must write your own function to get the desired post.

    $posts[] = get_post( FIRST_POST_FROM_CAT_Y );
    // ...

    You keep adding posts to the array for each category. How you generate the array of posts you can decide on yourself – you could also automate it completely if you want!

    the_wp_tiles( $posts );

    This expression actually outputs the tiles. So this has to appear actually at the place where you want to display the tiles – in a page template for example, or your own custom shortcode.

    Good luck!

    Mike

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Dynamic post to same tile which has a category’ is closed to new replies.