WordPress Customizing Custom Post Types? - php

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.

Related

How to make options for each page in wordpress

I am creating Dynamic wordpress template to publish it on themeforest and other Marketplace and i want to add specific options for each page (NOT options page) this options will show and the bottom of Add new page .
i wanna ask what is the name of this function or how i can add options like in the photo
You can research more on using wordpress custom fields,
Here is a good tutorial https://www.wpbeginner.com/wp-tutorials/wordpress-custom-fields-101-tips-tricks-and-hacks/
you can use ACF (Advanced Custom Fields) plugin for it. It is easy to create option for page, post, custom post using it and It has very good documentation.
here is the link :
https://wordpress.org/plugins/advanced-custom-fields/

How to change the 'Projects' permalink to the Category of the post in Wordpress

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

Make a custom taxonomy appear in adding posts (like category)

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.

include wp custom post templates in plugin

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

How to display a wordpress custom post?

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!

Categories