Custom post types - php

I have created a custom post type and it is working fine. Is there a way that we can distribute a custom post type in two parts for example when we register the post type it usually show this in the dashboard. All Products, Add new, categories. These three options are shown and when we click on add new then we enter data.I want this that their should also be add new 2 in the same menu. Some fields are shown in the add new and some shown in the add new 2.
Is this scenario possible in word press. If yes then please help me out how can i do this. I have searched a lot but nothing found yet.

If I understand what you want correctly, then yes its possible.
You would need to have 2 custom post types and use metaboxes.
Here is handful generator tools:
Custom posts Generator - http://fooplugins.com/generators/wordpress-custom-post-types/
Metaboxes generator - http://jeremyhixon.com/tool/wordpress-meta-box-generator/
(in post types set "custom" instead of "post" and type your custom post name).
as for merging 2 custom posts types under one menu in admin - please read Group Custom Post Types in one menu Wordpress solution.

Related

Wordpress - Hide specific fields to certain user role on back end

Is there a way in which I can disable/hide specific fields from the "page form" in the back-end? I have currently test two plugins but none of them meet the requirement that I have, like for example this plugin "User Role Editor by Members – Best User, Role and Capability Management Plugin for WordPress":
I'm sorry that the options are in spanish but the capabilities options are for example: "edit pages", "edit other people's pages", "publish pages", "delete pages"... What I want is to hide certain sections to the "editor" user role from the page form:
Is this even possible?, and if not, what alternatives do I have?, the thing is that I'm afraid that whoever is in charge of editing will end up messing up with the pages...
Use Adminimize plugin It will resolve problem easily.
This plugin changes the administration back-end and gives you the power to assign rights on certain parts.
In most cases, the plugin "Adminimize" that Tech Sourav mentioned will work just fine, but since this page I'm working with is using some annoying custom content editor and other theme tools, the workaround that I ended up doing was:
Create a custom post type with the "Custom Post Type UI" plugin.
In this case I will only and always have 3 pages that have this "modifiable" price field, so once the custom post type is added I added 3 entries to this custom post type (here I will show you just one).
I'm also using the "advanced custom fields pro" plugin in order to create this price field into my entries.
When the custom field has been created there's this option inside the same previous form that allows me to show that specific field just created into specific post types entries, so I made up the rules in order to show this field in the created custom post type entries:
In this example I'm just showing you the rule for one entry, in order to make it appear on the other 2 entries, I would just click in the "agregar grupo de reglas" and select one by one.
Once this custom field and rules are configured correctly, I should see now the custom field "precio" inside my specified entries form:
After saving the entry with the updated custom field value, I will now check the post id and save it for later (we're going to need it):
According to the documentation of Advanced Custom Fields plugin I can show the saved value of certain input within certain post with the shortcode: [acf field="{$field_name}" post_id="{$post_id}"], in this case I will change the values to: [acf field="precio" post_id="1372"] and paste the code into the section of the page that I will show this:
The builder that this page is using has an element called "code block" but you can use it in the equivalent element that allows you to paste code from your theme.
After saving the changes, now the only thing that I have left is to restrict the ability to edit pages to a user with the "editor" role, for this I will use the plugin that I mentioned before in my question called "User Role Editor by Members – Best User, Role and Capability Management Plugin for WordPress":
As you can see, I will not let editor users to mess up with the pages post types, so with this, they will only be able to edit the custom post type that I created, which even if they write something inside the content of that custom post type entry, the website won't be affected at all. This may be a little bit hacky but it works...

Use custom post type or custom group within another one

I am working on a wordpress website and I am using Advanced Custom Fields and Custom post type UI plugins. What I want to do is that:
The website I am working on was in native php and I want to migrate from native to wordpress but I face this problem, I can't achieve the relations that I had in mysql, in the form of post type and custom field groups in wordpress and ACF.
SO any have an Idea how to do this.
I also checked reusable fields but It actually won't help
https://github.com/tybruffy/ACF-Reusable-Field-Group
You didn't post your Data Model so it's hard to tell what the issues are or to give you an example based on it.
However, regarding the way Wordpress handles custom post type and meta value, I suggest that you consider post types as entities while meta values (custom fields here as you used ACF) usually their properties.
Usually, modelling 1-M or M-M relationships can be done in Wordpress by introducing custom taxonomies normally solve the problem, since it works as a mechanism to classify, to categorize and to group your entities. An example of this is the way Woocommerce give options to treat their product attributes as custom taxonomies. You can view the code from the link below.
https://docs.woocommerce.com/wc-apidocs/source-class-WC_Product.html#1398-1417

Common scenario in Wordpress: best practices

I'm facing a common scenario in the creation and the managing of a website that I'm still surprised I'm having difficulties in finding a good solution using Wordpress.
Let's say that I have a Wordpress website featuring food recipes. I have custom post types such as recipes and authors (of the recipes).
With the help of Advanced Custom Field plugin and Toolset plugin, it has been very easy to create the two custom post types and creating their custom fields together with the relationships between the objects.
Now, let's say that in multiple locations of the website I want to show a section called Spotlight Recipes where I show 3 featured recipes that I manually change every week.
What I would like to have in this situation, is a new item in the backend sidebar menu called Website Settings for example, that will allow me to manually choose the three recipes that will be featured in the section described above.
Let's say that I also want to display a section called Authors of the month and I always want to be able to manually choose the 5 authors that will be shown. It would be great if these could be also chosen inside the "Website Settings" backend page.
I think this is a very common scenario but I can't find a solution that I like. So I'm wondering: how websites using Wordpress solve this? Should I create a new custom post type called "MySettings" and create one instance of this, creating all its custom fields, and use it as a "singleton settings object"? It doesn't really appeal to me.
The best setup would be to add a new taxonomy for your Recipe custom post type. Then create a new category in that taxonomy named "Spotlight recipes".
You can add a custom taxonomy for users also.
There could be several scenarios for limiting the number of recipes shown. If you are declaring a recipe as recipe of the week as you add it then all you would need in your widget query is 3 parameters:
1) Set category to spotlight category of new taxonomy
2) Limit posts to 3 or 4
3) Sort by most recent
This way only the most recent recipes are shown at all times. It will also let you keep an archive of recipes of the week.

Custom input fields Wordpress back-end

I am working on a food-blog theme for Wordpress and I want the admin user to be able to add recipies in the back-end.
I'm thinking of a custom post format section similar to the regular post section where the user can add a title, the post itself, an excerpt etc.
I know how I can make such a section, but I want a custom field/row where the user adds an ingredient such as "water" and can add an amount and adds "grams"/"kilograms" etc. And do this for every ingredient.
I hope someone can help me with this, thanks!
Using Advanced custom fields
Documentation below
http://www.advancedcustomfields.com/resources/creating-a-field-group/
You can create fields that a user can insert data into and then you just parse that data into the the single page.
It is all documented nicely on the link above.

Wordpress - Custom Post Type with 3 input fields and

I am trying to modify wordpress for my needs:
I want a custom post type (well, thats basically easy), but instead of only 1 article section it should have three or more of them, divided by tags. All the div-tags should have one class in common (for example class="article"). The other classes should able to be assigned specifically, that means i'd like to have a little box beneath each of the article input fields, in which I can select different classes for each of the fields.
I have googeled a lot and didn't find anything. Are there any tutorials/blogposts on this or do you know any advice?
Thanks in advance,
JBG
hi you can create custom filed with http://wordpress.org/plugins/advanced-custom-fields/

Categories