Custom Post Types on Index have no layout

General questions pertaining to how certain issues can be resolved
Forum rules
1. No offensive language and no mocking
2. Please do a thorough search before you post something. Trust us, there is a high probability that the question you are asking has been asked previously.
3. No soliciting. You cannot post here soliciting bids for people offer you quotes, or even offer money to people for some work. You will be moderated if you do so. If you are looking for help, please post your request on http://jobs.wordpress.net or http://codepoet.com
4. Please be reasonable. You are getting software and support. For free. Complicated requests from a general purpose theme are not welcome and some volunteers might lose patience with you.
5. Please do your due diligence. If you posted a query and we answered with a link, take the trouble to go through the link contents.
6. Please post with complete information. Requests for help MUST be accompanied with your URL, particularly if you are asking something like "Why am I seeing a blank space?"

Re: Custom Post Types on Index have no layout

Postby sayontan » 31 May 2012, 08:32

tzdk wrote:But not sure what the issue is then. If you place that file correctly AND edit very same file custom code should also take effect.

The question is not that. The question is, "Why aren't the files visible in WP's file editor?" The answer is as I have written above - it is a WP shortcoming, which doesn't show the files.
Sayontan Sinha | http://mynethome.net/blog | http://www.aquoid.com/news
I don't do freelance work (for Suffusion or otherwise), so please don't contact me for quotes or offers.
sayontan
Site Admin
 
Posts: 10159
Joined: 15 Sep 2009, 16:39
Location: Houston, Texas

Re: Custom Post Types on Index have no layout

Postby tzdk » 31 May 2012, 08:43

Edit = wp editor = world is falling a part.

This editor works with Suffusion child theme http://wordpress.org/extend/plugins/adv ... de-editor/

Good developer.
tzdk
 
Posts: 42
Joined: 17 May 2012, 13:12

Re: Custom Post Types on Index have no layout

Postby tzdk » 31 May 2012, 08:50

But so does build in - I assumed it did not and activated this editor.

Well I use WP 3.4 so may be that is one of the new features? Check the screenshot. As you can see I use layout-blog.php which is in correct sub folder, with template-missing.php Structure of folders is visually lacking.

Even so still worth it to use better editor I think, if internal editor is preferred.

Possibly this really is a 3.4 feature, check this http://nacin.com/2012/03/29/page-templa ... press-3-4/ Not much longer before you can continue old habits then :)
Attachments
Screenshot - 31-05-2012 003.png
Screenshot - 31-05-2012 003.png (5.8 KiB) Viewed 453 times
tzdk
 
Posts: 42
Joined: 17 May 2012, 13:12

Re: Custom Post Types on Index have no layout

Postby mcfilmmakers » 31 May 2012, 09:09

I guess I'll wait for 3.4 and see if that solves the issue then.

In the meantime, I'm still looking to solve why custom post types aren't formatting the same way regular posts are in my index page...
mcfilmmakers
 
Posts: 60
Joined: 28 May 2012, 12:25

Re: Custom Post Types on Index have no layout

Postby Colin » 31 May 2012, 09:12

Try Notepad++ as your editor and filezilla as your FTP programme have both open and then just upload your files as you change them and check them out in your browser. In a lot of respects this is faster as 2 out of three are running locally and all you need to do is a browser refresh which is quicker. It also means that you have a copy of your bespoke code locally should something happen to the server. Remember a lot of hosts only back up once a week the better ones once a day but you can make a lot of changes in 24 hours.
Colin
 
Posts: 2798
Joined: 27 Oct 2009, 10:46

Re: Custom Post Types on Index have no layout

Postby mcfilmmakers » 31 May 2012, 10:10

So I can confirm that my theme does use my child's layout-blog.php file. While the editor ignores it, at least I know my theme doesn't.

PROBLEM SOLVED and it is an easy fix for the developer!

Your theme applies the class .post to all posts. The thing is, when a custom-post-type is used, the class .post becomes the class .custom_post_type name.

In my case, the post receives the class .vehicle.

The fix is quite simple. While you should (and do) assign a class to each post with the name of the post-type, you should also give each post a universal class (ex: .allposts) that would apply regardless of the post type.

This way, this universal post class would have all the CSS currently assigned to .post and the user can add css based on each post-type to differentiate them if he should want to.

The fix:

Change the line
Code: Select all
<article <?php post_class($custom_classes);?> id="post-<?php the_ID(); ?>">


to

Code: Select all
<article class="<?php echo $custom_classes; ?> allposts" id="post-<?php the_ID(); ?>">


*verify the above... the point is to add allposts as a class.

The result of the above is that the HTML output for regular posts would be
Code: Select all
<article class="post-1100 post type-contest status-publish hentry post-seq-1 post-parity-odd allposts" id="post-1100">


and for my vehicle custom post type it would be
Code: Select all
<article class="post-1100 vehicle type-contest status-publish hentry post-seq-1 post-parity-odd allposts" id="post-1100">


Notice allposts at the end of the classes and the second class being the name of the post-type.

The CSS then would need to change from
Code: Select all
.post, article.page {
   border: 1px solid #c0c0c0;
   background: #FFF;
   padding: 25px 15px 1em 15px;
   clear: both;
   overflow: hidden;
   margin-bottom: 10px;
}
.post .date {
   height: 48px;
   width: 48px;
   right: 58px;
   font: normal 150% Arial, Helvetica, sans-serif;
   color: #ffffff;
   text-align: center;
   padding: 0;
   line-height: 100%;
   margin-left: -100%;
   float: left;
   position: relative;
}

.post .date span.day {
   font: normal 100% Arial, Helvetica, sans-serif;
   color: #ffffff;
   text-align: center;
   padding: 0;
   line-height: 100%;
}
.post .date span.month {
   height: 12px;
   display: block;
   font: normal 50% Arial, Helvetica, sans-serif;
   color: #ffffff;
   text-align: center;
   padding-top: 2px;
}
.post .date span.year {
   height: 12px;
   display: block;
   font: normal 50% Arial, Helvetica, sans-serif;
   color: #ffffff;
   text-align: center;
   padding-top: 0;
}
.post .title {
   float: left;
   margin-left: 10px;
   width: 635px;
}
.post .meta-pullout span.author, .page .meta-pullout span.author {
   float: none;
   padding-right: 0;
}
.post .title {
   float: left;
   width: 100%;
   position: relative;
   margin: 0;
   padding: 0 0 0 10px;
}
.post .libtitle {
   float: left;
   margin-left: 0;
   width: 745px;
}


to

Code: Select all
.allposts, article.page {
   border: 1px solid #c0c0c0;
   background: #FFF;
   padding: 25px 15px 1em 15px;
   clear: both;
   overflow: hidden;
   margin-bottom: 10px;
}
.allposts .date {
   height: 48px;
   width: 48px;
   right: 58px;
   font: normal 150% Arial, Helvetica, sans-serif;
   color: #ffffff;
   text-align: center;
   padding: 0;
   line-height: 100%;
   margin-left: -100%;
   float: left;
   position: relative;
}

.allposts .date span.day {
   font: normal 100% Arial, Helvetica, sans-serif;
   color: #ffffff;
   text-align: center;
   padding: 0;
   line-height: 100%;
}
.allposts .date span.month {
   height: 12px;
   display: block;
   font: normal 50% Arial, Helvetica, sans-serif;
   color: #ffffff;
   text-align: center;
   padding-top: 2px;
}
.allposts .date span.year {
   height: 12px;
   display: block;
   font: normal 50% Arial, Helvetica, sans-serif;
   color: #ffffff;
   text-align: center;
   padding-top: 0;
}
.allposts .title {
   float: left;
   margin-left: 10px;
   width: 635px;
}
.allposts .meta-pullout span.author, .page .meta-pullout span.author {
   float: none;
   padding-right: 0;
}
.allposts .title {
   float: left;
   width: 100%;
   position: relative;
   margin: 0;
   padding: 0 0 0 10px;
}
.allposts .libtitle {
   float: left;
   margin-left: 0;
   width: 745px;
}


The user is then free to further customize the CSS for posts, and each custom post type individually.

Here's hoping this fix makes it into the next version of either the theme or the custom post types plugin since this is fairly simple (though not obvious) and makes the theme that much more powerful when it comes to post-types!

As an intermediate step to get people to transition without issue, you could make the CSS look like this:

Code: Select all
.allposts, .post, article.page, {
   border: 1px solid #c0c0c0;
   background: #FFF;
   padding: 25px 15px 1em 15px;
   clear: both;
   overflow: hidden;
   margin-bottom: 10px;
}
.allposts .date, .post .date {
   height: 48px;
   width: 48px;
   right: 58px;
   font: normal 150% Arial, Helvetica, sans-serif;
   color: #ffffff;
   text-align: center;
   padding: 0;
   line-height: 100%;
   margin-left: -100%;
   float: left;
   position: relative;
}

.allposts .date span.day, .post .date span.day {
   font: normal 100% Arial, Helvetica, sans-serif;
   color: #ffffff;
   text-align: center;
   padding: 0;
   line-height: 100%;
}
.allposts .date span.month, .post .date span.month {
   height: 12px;
   display: block;
   font: normal 50% Arial, Helvetica, sans-serif;
   color: #ffffff;
   text-align: center;
   padding-top: 2px;
}
.allposts .date span.year, .post .date span.year {
   height: 12px;
   display: block;
   font: normal 50% Arial, Helvetica, sans-serif;
   color: #ffffff;
   text-align: center;
   padding-top: 0;
}
.allposts .title, .post .title {
   float: left;
   margin-left: 10px;
   width: 635px;
}
.allposts .meta-pullout span.author, .post .meta-pullout span.author, .page .meta-pullout span.author {
   float: none;
   padding-right: 0;
}
.allposts .title, .post .title {
   float: left;
   width: 100%;
   position: relative;
   margin: 0;
   padding: 0 0 0 10px;
}
.allposts .libtitle, .post .libtitle {
   float: left;
   margin-left: 0;
   width: 745px;
}


This above CSS will not affect sites currently using the theme nor will the modifications to the layout file.

Also, the php code change needs to be applies to ALL the layout files (layout-blog, layout-tiles, layout-mosaic, layout-list).
Last edited by mcfilmmakers on 31 May 2012, 10:46, edited 2 times in total.
mcfilmmakers
 
Posts: 60
Joined: 28 May 2012, 12:25

Re: Custom Post Types on Index have no layout

Postby sayontan » 31 May 2012, 10:36

mcfilmmakers wrote:The formatting works if the post type of the post is 'post' but the formatting goes away if the custom post type is anything else. Question is why and I have yet to discover the answer :(

The solution was in my first response - you need to add the "post" class to each displayed post. Without a URL I can't help you beyond this point.
Sayontan Sinha | http://mynethome.net/blog | http://www.aquoid.com/news
I don't do freelance work (for Suffusion or otherwise), so please don't contact me for quotes or offers.
sayontan
Site Admin
 
Posts: 10159
Joined: 15 Sep 2009, 16:39
Location: Houston, Texas

Re: Custom Post Types on Index have no layout

Postby mcfilmmakers » 31 May 2012, 10:49

sayontan wrote:
mcfilmmakers wrote:The formatting works if the post type of the post is 'post' but the formatting goes away if the custom post type is anything else. Question is why and I have yet to discover the answer :(

The solution was in my first response - you need to add the "post" class to each displayed post. Without a URL I can't help you beyond this point.


Yes, you were right. But my solution goes a step further. It ensures the user doesn't need to worry about the formatting regardless of post-type AND can go the step further to customize each post-type (like change the background of each post-type) very easily, without modifying any php files at all.

That's why I hope for it to be integrated in the next version as it eliminates the need to modify php files entirely.
mcfilmmakers
 
Posts: 60
Joined: 28 May 2012, 12:25

Re: Custom Post Types on Index have no layout

Postby sayontan » 31 May 2012, 11:21

mcfilmmakers wrote:Yes, you were right. But my solution goes a step further. It ensures the user doesn't need to worry about the formatting regardless of post-type AND can go the step further to customize each post-type (like change the background of each post-type) very easily, without modifying any php files at all.

That's why I hope for it to be integrated in the next version as it eliminates the need to modify php files entirely.


Your two requirements are at odds with each other. If you had specifically stated what you wanted I would have given you a PHP-free solution. Each post gets a class corresponding to its post type. So you could have very easily added a single line of CSS and done with it:
Code: Select all
article.type-vehicle { background: url(...); }

That's it - no, PHP changes required, and this approach works with just about everything. Instead, based on the information that you had provided, I assumed you just wanted your CPTs to be formatted like regular posts, hence I gave you the approach that I did. Of course, in the above code you could have specified the URL for your post background and that would have worked just fine as well, but I have no clue as to what your setup looks like.

There will never be a day when Suffusion will provide options for EVERYTHING. I have to draw the line somewhere, and in this case, the line just moves a bit further: the next version has the capability to specify a CSS class for each post type, that's all. This is where my subjectivity comes in. For the most part I offer capabilities via the UI that people would otherwise have to code, but I don't bother too much with changes pertaining to stylesheets: they are easy for an end-user and only require putting something in the "custom includes" section.
Sayontan Sinha | http://mynethome.net/blog | http://www.aquoid.com/news
I don't do freelance work (for Suffusion or otherwise), so please don't contact me for quotes or offers.
sayontan
Site Admin
 
Posts: 10159
Joined: 15 Sep 2009, 16:39
Location: Houston, Texas

Re: Custom Post Types on Index have no layout

Postby mcfilmmakers » 31 May 2012, 13:23

Well your solution is equally valid. I just thought I'd mention my solution. I definitely understand that a line needs to be drawn somewhere.

That said, I realized that while the custom-post-type plugin allows you to assign your custom taxonomies to multiple post-types, including post, it does not allow the built-in taxonomies to be assigned to your custom-post-types.

By that I mean that the plugin does not allow the Categories and Tags taxonomies built into Wordpress to be assigned to your custom post types.

The only work around is to use the following code in my functions.php file (of which the last line is the important part
Code: Select all
add_action('init', 'demo_register_post_type');
 
function demo_register_post_type() {
    register_post_type('demo', array(
        'labels' => array(
            'name' => 'Demos',
            'singular_name' => 'Demo',
            'add_new' => 'Add new demo',
            'edit_item' => 'Edit demo',
            'new_item' => 'New demo',
            'view_item' => 'View demo',
            'search_items' => 'Search demos',
            'not_found' => 'No demos found',
            'not_found_in_trash' => 'No demos found in Trash'
        ),
        'public' => true,
        'supports' => array(
            'title',
            'excerpt'
        ),
        'taxonomies' => array('category', 'post_tag') // this is IMPORTANT
    ));
}


The above invalidates the use of the plugin and makes it difficult to migrate to a new theme unless you copy the above code into that theme, and isn't the whole point of the plugin to avoid that?

I understand the point of the plug-in is to provide a UI to add Custom-post-types but I am sure users would benefit more from it if Categories and Tags were recognized as already established taxonomies that cannot be deleted. This way, users can assign them to their custom-post-types using the UI.

There would be no benefit to adding Posts as a pre-established post-type but why not list it as one that cannot be deleted so users can recognize Posts as a post-type just like any other?

I must say, I am grateful of this forum and am thankful to you for offering such a wonderful theme and plug-in!
mcfilmmakers
 
Posts: 60
Joined: 28 May 2012, 12:25

PreviousNext

Return to Support Requests

Who is online

Users browsing this forum: crucialjb8z, Google [Bot], moorrene and 1 guest