Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author ethanhackett

    (@ethanhackett)

    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.

    Thread Starter brooklyncreativedesign

    (@brooklyncreativedesign)

    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…

    Plugin Author ethanhackett

    (@ethanhackett)

    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 https://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.

    M

    (@metacomcreative)

    +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!

    Thread Starter brooklyncreativedesign

    (@brooklyncreativedesign)

    @ryan – what did you change $the_query too? Can you post your change?

    M

    (@metacomcreative)

    @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;
    Plugin Author ethanhackett

    (@ethanhackett)

    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?

    Thread Starter brooklyncreativedesign

    (@brooklyncreativedesign)

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

    M

    (@metacomcreative)

    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.

    Thread Starter brooklyncreativedesign

    (@brooklyncreativedesign)

    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')'

    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’]

    M

    (@metacomcreative)

    @cocha – Awesome work! I’ll try this out later today. Thanks for sharing.

    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.)

    … 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) …

    Thread Starter brooklyncreativedesign

    (@brooklyncreativedesign)

    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!

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Post Tiles & Custom Post Type’ is closed to new replies.