Now, to display the post on the front end.
You can go more in-depth about all the options of creating a custom post here. array ( 'name' => _ ( 'Your Post' ), ), 'public' => true, 'hierarchical' => true, 'has_archive' => true, 'supports' => array ( 'title', 'editor', 'excerpt', 'thumbnail', ), 'taxonomies' => array ( 'post_tag', 'category', ) ) ) register_taxonomy_for_object_type ( 'category', 'your_post' ) register_taxonomy_for_object_type ( 'post_tag', 'your_post' ) } add_action ( 'init', 'create_post_your_post' )
Here's the code that will go into functions.php. You can call it whatever you want, but it might be easiest to practice the first time around with the same names I used. I'm going to create a custom post called Your Post, with the id your_post. I'm starting off with a completely empty WordPress theme, just like in part one. I promise I'll make it as simple as possible.Īnything throughout this article prefixed with your_ is custom, and you can change the name. It's basically a simplified version of what Advanced Custom Fields does, but without any plugins.
Have you ever wanted to add another upload field for images outside of the "Featured Image" thumbnail option? In this article, we'll also learn how to add an upload button and browse through the media gallery to insert an image. The gist of it is, have you ever wanted to add an extra field to a WordPress post? Maybe a date, or a URL, or an e-mail address? We're going to learn how to do that. There are a lot of WordPress-specific words going around already, and it's more confusing than I'd like. If not, you can still do this tutorial from scratch as long as you have a basic knowledge of WordPress. If you've been following along, you can just add this on to what you already have. This tutorial is independent of the previous installments. Basic knowledge of WordPress functions and custom post types.Basic knowledge of WordPress and how to create your own theme.And it's going to be easy, you'll love it. In part three, we're going to learn how to add basic custom fields to a post, save them in the database, and show them on the front end of the website, without a plugin. In part two, we learned more advanced concepts like adding comments and images. (dot) followed by a unique name for your box, then insert the CSS codes.In the first part of my WordPress tutorial series, we learned what WordPress is and how to create and use a basic theme. Right before the queries begin, insert your custom CSS for content boxes there. Go to cPanel, file manager, go into the public_html folder, (or the subdirectory for an addon domain), and find the theme you want to add the custom content boxes into. You can edit the stylesheet to include your own custom text boxes.Īs an example, if you wanted to use yellow content boxes, you can add a section to your style.css for a “content-box-yellow”. The style.css is what controls all the styling elements for each theme. If you have a particular type of content box you want to design with CSS then use it repeatedly across multiple pages (without having to code it every single time) use this option. How to hardcode content boxes into your WP themes style.css template Once the styling CSS is set in the customizer, any time you insert the into the HTML of your post or page, your custom text input field will show. For the colors, search online for a list of CSS color names, or if you know the hex code for the color you want, insert that instead.