Okay, so I am completely lost on how to display a custom post. I've looked everywhere and can't seem to wrap my mind around it.
So, I downloaded the plugin Custom Post Type UI to create a custom post. Here are the parameters of my custom post type:
Name: discount
Label: Discount
Supports:
title,
excerpt,
thumbnail,
author
Then, I downloaded Advanced Custom Fields to give my custom post types some custom fields for users to edit.
I didn't have any problems with that. My problem is that I have no idea how to implement this into my site. I would like it to act exactly like a blog post and also implement a masonry for it - just like my blog posts (I'm using the dante theme (I can't post any more links)).
If anybody could help me out with this, or send me in the right direction, I would be so greatful. Thanks!
Your custom post type's theme template would be called "single-[post type name].php".
So for your example, you would want to create single-discount.php if your theme's root directory. Then you can start pulling your data from the posts through that.
For Advanced Custom Fields, you'll want to get familiar with get_field() and the_field(). ACF has great documentation on their site for how to use the various field types (http://www.advancedcustomfields.com/resources/)
To answer your questions in a general way, you could start by:
Theme Development. To understand how a WP theme works
Template Hierarchy. To understand what are the template files and how they are managed by WP
The Loop. To understand how WP shows the post
WP Query Class. To understand how to manage the posts, perhaps in the case of custom post type
For the custom fields, #Joe has pointed you in the right direction.
Hope it helps!
Related
I would like to change the permalinks for projects to use the specific post's parent category name. Is this possible? I have come across a few tutorials via Google, though none seem specific to this cause.
I am currently using the Wordpress Projects section for Events and a Menu (restaurant). I would like the URLs associated with the posts in each of those categories to be /events/post-name and /menu/post-name
From:
www.website.com/projects/post-name
To:
www.website.com/events/post-name
www.website.com/menu/post-name
The Yoast SEO plugin can help you for doing this kind of URL manipulation.
Also, it seems you need to create Custom Post Types for your different kinds of contents. In your case, you can create an Events post type and a Menu post type.
There are several plugins available to help you with Custom Post Types, for exemple: Custom Post Type UI, Toolset Types...
And this one: post-type-switcher can be useful if you want to transfer your existing content in a newly created Post Type.
Hope it will help
I'm using different page-templates this for pages.
Now I need the same for posts.
Since 4.7 this should be a core functionality.
So I pretty much followed this quick tutorial and added a custom single-duplicate.php in my theme folder and added this code at the top:
<?php
/*
Template Name: Full-width layout
Template Post Type: post, page, product
*/
However upon creating a new post I dont see the "Post Attributes" Box with the Template-dropdown. What do I do now? Is it possible that my theme somehow prevents that?
Here's my themes functions.php as a gist, if that helps.
I think you are a bit confused as to what Page Attributes will give you access to. To the best of my knowledge, you do not get a drop down to choose a template (as you do on Pages) as an automatic function on posts/custom post types.
you need to create a single-{POSTTYPE}.php in your theme directory and need to add/follow the HTML structure of your page template.
For more information,
Custom Post Type page template doesn't show up
Post Template Files
Hope this will helps you.
I've been asked to add post section to a customers WordPress website. Being fresh to wordpress i'm new on the terminology of the features of wordpress. In the menu i can see the existing two items as follows:
They've got "Posts" and "Properties" and now they want to add something the same as "Properties" but a different category called "Properties for Sale".
In WordPress are these sections referred to as "Custom Post Types"? Am I right to just install a plugin and create a new Custom Post Type?
Any advice would be appreciated.
There are many plugins to create post types. Custom Post Types definitely does the job. Once you activate it you should be able to create your own post types.
If you don't want to use a plugin, there is a way to do it yourself either in functions.php or in your own plugin. For a beginner, however, using a plugin is the easiest way.
There already is a plugin of some sorts installed for this. The "Custom Post Types" menu item is not native to WP.
I'm developing over a premium theme , I have some already registered taxonomies. Those taxonomies appears on the right side bar when creating custom posts (or custom pages not sure) that are related to the theme (and its plugins).
The thing is, such ability to choose from those taxonomies doesn't appear when creating 'normal' posts. How can I make it appear there too?
What I've done so far is follow this post, so I created a plugin and activated it. It have code like this
add_action('plugins_loaded','add_spTaxonomy_pt');
function add_spTaxonomy_pt(){
register_taxonomy_for_object_type('actual_taxonomy_name', 'post');
}
?>
But that didn't help. What should I do?
According to Wordpress Codex:
Use register_taxonomy_for_object_type() right after the function to interconnect them. Else you could run into minetraps where the post type isn't attached inside filter callback that run during parse_request or pre_get_posts.
Is it possible to use an earlier hook maybe? The code looks alright otherwise.
I trying to include two theme template files into a wp plugin that deals with custom post types and for the life of me cant figure out a way to do it, I have searched extensively and believe posting here is the best option if I am to find an answer.
The custom post type is videos which is using single-video.php as the single template and category-253.php for the category and am wanting to move them from the child theme into the plugin/includes/templates directory so the plugin is independent.
Anyone have any ideas ?
this should cover what you are looking for
http://tommcfarlin.com/page-template-in-plugin/
but as far as plugin integration, you can try the shortcode method to display template codes from plugins
[myshortcode parm=1 parm=2 parm=3]
to do something in a plugin like for example list your custom post with different options