WordPress.org

Ready to get started?Download WordPress

Forums

Post Tiles
Post Tiles & Custom Post Type (18 posts)

  1. brooklyncreativedesign
    Member
    Posted 1 year ago #

    I am trying to use this plugin on a second page to display posts from a custom post type, and it doesn't seem to be working.

    The website is http://www.reignministries.org - The post tiles are working perfectly on the bottom of the homepage using the main post feed.

    I am then trying to use the post tiles a second time to display a custom post type called "Staff Members" which has a category id of 310. The URL for this page is: http://www.reignministries.org/staff

    Any thoughts as to why it would not be pulling the posts from this custom post type?

    http://wordpress.org/extend/plugins/post-tiles/

  2. ethanhackett
    Member
    Plugin Author

    Posted 1 year ago #

    Unfortunately Post Tiles isn't designed with custom post types in mind. They ad a whole other level of complexity which I haven't even explored. I'll add this to the possible features list for future versions.

  3. brooklyncreativedesign
    Member
    Posted 1 year ago #

    Why though, if the custom type has a category ID number, can it not be read by post tiles? I suppose that is where I am getting lost...

  4. ethanhackett
    Member
    Plugin Author

    Posted 1 year ago #

    They're stored and called individually by custom post type. Even though it may have an id. The idea is that the custom post types don't get accidentally pulled in when querying normal posts.

    You could try modifying lines 371-379 and look to something like this article http://wordpress.stackexchange.com/questions/6417/query-for-custom-post-type

    You might be able to tweak it to query both posts and custom post types together.

  5. Ryan Cowles
    Member
    Posted 1 year ago #

    +1 for use with Custom Post Types ;)

    @Brooklyn – As Ethan mentioned, you can alter the query to pull your CPT's. I was able to do that by modifying $the_query on line 379. However, this won't alter the admin options, or the category key.

    I'll keep poking around and see if I can come up with anything.

    Thank you for sharing your plugin, Ethan!

  6. brooklyncreativedesign
    Member
    Posted 1 year ago #

    @Ryan - what did you change $the_query too? Can you post your change?

  7. Ryan Cowles
    Member
    Posted 1 year ago #

    @Brooklyn - Sorry, I should have included it, haha. I just added it to $the_query. Not the cleanest way, but for testing purposes it did the trick.

    Line 379 becomes:

    $the_query = $posts_query.$cat_query.'&post_type=YOUR_CPT'.'&paged='.$paged;
  8. ethanhackett
    Member
    Plugin Author

    Posted 1 year ago #

    Ryan thanks for posting in the code. I'll explore adding this into the short code. Did it work with both post types at the same time?

  9. brooklyncreativedesign
    Member
    Posted 1 year ago #

    @Ryan/@Ethan - The issue I see here, is that it can then either pull the CPT or the normal posts, but not both. Right?

  10. Ryan Cowles
    Member
    Posted 1 year ago #

    The line that I mentioned above would only pull from whatever CPT that you specify.

    If you wanted to pull a CPT and regular posts, you should be able to just alter WP Query's Type Parameters.

    The example in the Codex shows that 'post_type' can accept an array.
    $query = new WP_Query( array( 'post_type' => array( 'post', 'page', 'movie', 'book' ) ) );

    If you wanted to pull all post types, you could use post_type=any. I haven't tested this out, but perhaps it will point you in the right direction. If I have some time later I will see if I can put together a solid example.

  11. brooklyncreativedesign
    Member
    Posted 1 year ago #

    Ryan - 'post_type=any' pulls everything, including pages. It works perfectly, just includes pages as well. So it gets me closer, but not quite. I've tried playing around with calling an array, but with no luck.

    What I used but doesn't work. (my CPT is "staffmembers):

    '&post_type=array('post','staffmembers')'

  12. CoCha
    Member
    Posted 1 year ago #

    What I did to show pages (and probably any CPT) using post-tiles:

    First of all I installed a plugin called Post Tags and Categories for Pages to be able to use categories for pages.

    Secondly I made some minor changes to the original source code by adding an extra shortcode option 'type':

    // Defaults
       extract(shortcode_atts(array(
          "categories" => '',
          "posts" => '',
          "excerpt" => '',
          "type" => ''
    ), $atts));

    Then I changed $the_query into

    // Configure post_type
       $type = $atts['type'];
       if (isset($type)) {
           $type_query = '&post_type='.$atts['type'];
       }
       else {
    	   $type_query = '&post_type=post';
       }
    
       // Configure Both Categories and Number of Posts For Query
       $the_query = $posts_query.$cat_query.$type_query.'&paged='.$paged;

    This shortcode now works for me:
    [post-tiles categories='590' type='page' posts='12' excerpt='18']

  13. Ryan Cowles
    Member
    Posted 1 year ago #

    @CoCha - Awesome work! I'll try this out later today. Thanks for sharing.

  14. CoCha
    Member
    Posted 1 year ago #

    In addition to my previous reply:

    There were a few more things I wanted to control:
    Since my blog has a few different page/post-width (depending on the CPT used), I wanted to have more width and height-options.
    So I just extended the shortcode as before and added 'width' and 'height'.
    Then I changed the following (search for '\\ Retrieves Tile Width')

    // Retrieves Tile Width
    	   $posttiles_li_width = get_option('posttiles-width');
    	   $li_width = $atts['width'];
    	   if (isset($li_width)) {
    		  $posttiles_li_width = $atts['width'];
    	   }
    	   if(empty($posttiles_li_width)){
    	   	  $posttiles_li_width = "175";
    	   }
    	   $posttiles_width = $posttiles_li_width-20;

    (same changes made for Height of course)

    Now I'm able to do something like this:
    [post-tiles categories='773' type='page' width='120' height='120' posts='16' excerpt='18']

    By using an additional plugin called Page Links To and combining this with my previous reply you even can have a tiled link to an URL! (i.e. just create a page per link and assign it to an 'external-url'-category or something like that.)

  15. CoCha
    Member
    Posted 1 year ago #

    ... Oops, I may have forgotten one essential change regarding sizes I've made a while ago: the 'background-size:contain'-addition to $featured-style may be crucial (or not) ...

  16. brooklyncreativedesign
    Member
    Posted 1 year ago #

    Any thoughts on how to use the categories with a CPT? I've been able to alter the query to be able to pull the CPT posts, but need the categories to go along with them. Suggestions on that?

    @CoCha - thanks for introducing me to the 'Page Link To' plugin. Sure simplifies some things!

  17. EDWINXX
    Member
    Posted 1 year ago #

    Hi, i would like to see something like this

    [post-tiles date=true categories='1']

    example:

    18-06-2013
    POST TITLE

    text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text

    I don't have a lot of php training so i do not know how to setup this in de code

    please help me out, thanks

    Kind regards, Edwin

  18. bdalte
    Member
    Posted 1 year ago #

    Hello,

    Thanks in advance for getting this plugin alive.

    I'm facing so much troubles on post tiles, that after 3 days trying to solve it by myself it's enough.

    Can i get some help?

    in first place, i've to let you know that i'm a noobie, but with a lot of willness to get things done my myself without troubling no one.

    My problem is that i can't get Post-Tiles to work.

    My first attemp was close, cause i manage to display the regular posts, then again i went closer, cause i don't know why/how i managed, with no need of changing .php what so ever, display custom posts but without images... after that, there was nothing... i can only see my shortcode in the frontend. Can't understand why! Already tried to deactivate, delete and reinstall the plugin... but nothing.

    Can i get some help here?

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.