wordpress : how to use a custom HTML file to create a new post? - wordpress

I have generated pages using a custom template by creating a php file in
/wp-content/themes
something like :
<?php
*
* Template Name: Contact Page
*/
?>
<html ..... </html>
and then adding a new page on the dashboard selecting this new template
The problem is i cannot associate tags and categories to each pages.
i would need apparently instead to create posts.
How could i then create posts from a custom html file ?

Use custom post types and create a single-{posttype}.php
I think this will solve your problem.

Custom post types are exactly what you need. Essentially, they're custom content containers and an extensible version of default posts. They can be associated with tags and categories just like normal posts can.
You can find implementation instructions here. :)

Related

Use custom templates in posts (not pages)

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.

Wordpress custom single post page

so i need to create a custom single post page in wordpress according to a client's specification on a mock up of the page. It's gotten quite difficult trying to customize the single post page of the theme i'm currently using. What can i do to make the single post page look exactly like the one in the mock up because both look way different from each other. This is the mock up of the proposed page
You have to options either you can goto child theme and customize your post template single.php or like example (themes\twentyseventeen\single.php)(themes\twentyseventeen\template-parts\post\content.php) and apply your design there or you can create new template for single post.
New template
<?php
/*
* Template Name: New Template
* Template Post Type: post
*/
get_header(); ?>
// your html design and content of post
// along with the post loop
<?php get_footer(); ?>

Changing the "standard template" name of the single.php post template

I have a Wordpress website, now i want to change the post template name how it displays in the Wordpress CMS. Now it's saying "Standard template", i want to rename this to "News", just for usability reasons.
I can't find a way to do this. I know you can create new post templates by creating new files, but it always takes the single.php as standard template. I'm also using a child-theme, so i dont want to delete the single.php file, just rename the text: "Standard template".
Thanks in advance.
I tried creating a new post template file with a custom title. This doesnt solve problem, as the single.php file will still be the standard one (i dont want the user to have to change the template).
You can use another single.php for another post type for example if you have news registered as a post type you could have a single-news.php and that file then would server all the single views of postype = news. But from what i understand you would like to create a template appearing to the user with a different name. For that the best practice is to create a directory inside your child theme and name it page-teplates. Inside this directory you can create as many different templates you want and wordpress will recognize them but adding the following code at the top of each template. For the sake of the example lets say i want to create a contact page template. I will create a contact.php file inside the directory page-templates and have these lines of code inside.
<?php
/**
* Template Name: Contact
**/
get_header();
/* My templates Code/Design Here */
get_footer();
The possibilities are endless.
The code in this post will generate a dropdown box similar to the one that you see in pages.
All it requires is a little editing of your child themes functions.php file .
In most cases, you just need to copy your single.php file to a new file name in your child theme and edit the functions.php file in your child theme. Name your templates as seen in the code Dimitrios posted.
consider using the premium elementor page builder to create custom post templates that you can apply at will.
Try a plugin like Post Custom Templates Lite

In WordPress how to add post to custom 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.

creating wordpress custom php page

I'm trying my make my first theme for wordpress.
Is there any possibility to create custom php page to display custom content?
Pretty much adding to WordPress another copy of the likes of single.php, post.php or 404.php.
All I want just a page to display the custom content on it.
Every tutorial I found so far uses just creating new page within WordPress.
I want to avoid it and for custom page to be enabled straight after theme activation.
The Idea is to have something like my_custom_page.php and to be able link to it after.
Is there any way of doing it?
Thanks
here is the solution to what I was looking for
http://kovshenin.com/2014/static-templates/
To achieve custom page functionality you can use page template concept of wordpress. Creating a page template is extremely easy. Create any new file in your theme and start the file with a comment block like so:
<?php
/*
Template Name: My Awesome Custom Page
*/
<h1>Hello There</h1>
You need paste php code inside this template file. When you submit for then redirection action will be page with custom template page.
Referance :
https://premium.wpmudev.org/blog/creating-custom-page-templates-in-wordpress/
Video :
https://youtu.be/1ZdHI8HuboA

Resources