I have a created a custom WordPress Theme.
All the Posts have a different layout and Pages have a different layout.
By default for Posts wordpress uses index.php and content.php
By default for Pages wordpress uses page.php and content-page.php
I have created two different posts.
What I want to know is how to display one post in the page template layout and the other post in post template layout?
Is this possible?
Please help.
Yest this is possible by using a Plugin named - Custom post template.
Here is the link to the plugin: http://wordpress.org/plugins/custom-post-template/
No,It is not possible to do.Different Posts is a normal post type called posts.And pages are called Page.
So you can not mess up with pages and posts.Please see wordpress codex templates
http://codex.wordpress.org/Templates
In your template you create a template called template-post.php and template-page.php
At the beginning of the file you need to use
<?php
/**
* Template Name: Page Builder
* Template Post Type: post, page
* #package WordPress
*/
Please note the Template Post Type: post, page.
Now the templates are available for both posts and pages.
Related
Is there a way to allow the user to select a template for a post in the same way you can select one for a page?
I could create a new post type and create a single.php file for that type, but there are several templates to add I it would mean when I am pulling in posts, I would have to add those post types to the feed throughout the site, so I would like to avoid it if possible.
Sure, you can use the same process as for page templates by creating your single file with this header at the top of the file:
<?php
/*
* Template Name: Featured Article
* Template Post Type: post, page, product
*/
get_header(); ?>
Then on the dashboard, you will be able to select the template for your post.
I am making custom CRUD method in WordPress so i need to add custom php page in WordPress.
There is no one option like a template in add new page option. so how can i do it?
1/ Create custom template
<?php
/*
Template Name: Your_Template_Name
*/
// YOUR PHP
2/ Create PAGE in Back Office with YOUR_TEMPLATE
OR
https://codex.wordpress.org/Creating_Options_Pages
I am new to WordPress.
suppose i have made pages as follows
home, news, about us
now if i want to create post for news page only
news1,
news2
then posting new post how could i set this settings?
You can create page templates.
Create one for all your pages.
Then, change the template of the page of news to the news template.
In that PHP file now you can do whatever.
For example, for news.php
<?php
/*
Template Name: My Custom Page
*/
//Here comes your PHP code, where create a $WP_Query(); and loop troough on that.
I am designing a website in wordpress. I have 1 custom home page & another are single themed pages. Now I want to add some more landing pages with different design. How can I get this?
create new php file in your theme directory, add this on the top of your php file:
<?php
/*
Template Name: your template name
*/
?>
use the template by choosing page templates on post option.
I am relatively new to wordpress, I am creating a custom theme, and so far it is going ok.
I currently have index.php, header.php, footer.php and sidebar.php.
I have now hit a bit that has been puzzling me for a couple of days.
My home page has a slightly different layout to other pages, how do I theme for that change?
My website is essentially made up, of 'static' pages and 2 posts pages, what can I do so that the homepage looks different to the other pages?
Create a page template called home.php. WordPress will use it automatically for the start page.
Example:
<?php
/**
* Template Name: Home
*/
get_header();
// Do your regular page.php stuff
get_footer();
See also the codex page an Conditional Tags.
Go into your dashboard, settings>reading, check what the setting is for your home page display. You may need to change it from the default "list of latest posts" to a static page of your choosing.
You need a front-page.php
Please see the template hierarchy
You need to use the built-in functions from wordpress such as is_home() and is_front_page().
Conditional Tags
If you have a front-page.php that will take precedence over home.php or page.php. Whether or not home.php or page.php are defaulted to (assuming you have both) can be controlled in Settings → Reading. If you do not have a front-page.php, home.php, or page.php, then index.php would be defaulted to.
One difference between home.php and front-page.php is that home.php defaults to being a blog index page. Though both home and front-page may be used to display static or blog index pages.
More info may be found Wordpress' Template Heirarchy page.