Multiple custom post types on index page with custom templates

There are a couple of confusing points to the question, namely that the home page is usually reserved for a stream of posts (where you could at one time trigger a 4 posts across layout, not necessarily all of them of the same post type), or a static post / page, where a such a check would be meaningless.

Still, I think you’re better off thinking in terms of Template Hierarchy, rather than checking for post type via functions. As in, creating actual files that are automatically loaded by WordPress without the need of additional code.

For example, put the following files in your template’s root directory: single-one_column.php, single-two_column.php, single-four_column.php, each of them containing or requesting the code within the files your trying to include, and WordPress will load them every time a user requests a post of that particular post type.

But since you’re trying to load more than one post at a time, maybe you need archive templates, which are also available for post types. It works the same way, i.e. archive-one_column.php, archive-two_column.php and archive-four_column.php, where you will be able to control the number of posts displayed and the layout when (assuming you have pretty permalinks) a user visits yoursite.com/one_column, etc.

If you do need everything to happen in that one page, keep in mind that the get_post_type() function without any parameters needs to happen inside the loop in order to work. It’s hard to say without seeing the complete page, but the problem might be that your trying to load your custom templates (where you have your custom loops) based on information that WP hasn’t yet processed.

But if you’re going to have queries that specifically request one post type, why would you need to use get_post_type() in the first place?

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)