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.
Related
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...
Ok, so my client has a database which has 500+ posts, and he wants me to create the second database where custom post type should place and read data from it.
The reason why is because there will be an option for visitors to come and fill the form that will write in database columns and save as draft post for admin to review. After validation from dashboard admin will publish that post and post will list in custom post type archive page. Custom post type also has custom taxonomy.
How would I go about using a different DB for only those custom post types, for reading and updating?
For that, you could use the multisite functionality in Wordpress
that will provide you the facility to create the tables in the same database but with a different prefix.
Hope this will help you out.
For a training center website i need a wordpress plugin that can store trainee information like name, batch no, phone no, email and a picture. That i can show in a page in grid view. please suggest me some wordpress plugin or any other way that i can do it. Thanks in Advance.
If you must use WordPress for this (not ideal) then one way is to register your trainee as a user and use a user meta plugin such as Meta Box to add additional fields to the user page: https://wordpress.org/plugins/meta-box/
Then use the get_user_meta function to retrieve the stored values and display them on a page: https://codex.wordpress.org/Function_Reference/get_user_meta
My favourite way is with custom post types. It might be a bit more work than installing some plugin and forgetting, but you are in control of everything and can adjust your code as needed.
Generate code for post type - https://generatewp.com/post-type/
Add it to your functions.php
Install ACF - https://wordpress.org/plugins/advanced-custom-fields/
and add the fields to your custom post type.
Add some users from the admin to the trainee post type
Select your trainee users and print them out.
Some links that might be usefull:
Post type templates so you can print out all trainees on trainy archive page - https://codex.wordpress.org/Post_Type_Templates
(You can skip this and add the post selection loop and printing out in some other page.)
How to get yout trainee posts - https://wordpress.stackexchange.com/questions/6417/query-for-custom-post-type
ACF get_field() function to get custom post data https://www.advancedcustomfields.com/resources/get_field/
I have been looking for a solution to display custom field tabs in the Joomla
front article edit page.
http://www.aixeena.org/extensions/aixeena-easy-cck
Aixeena Easy CCK
I installed the plugin of aixeena, two custom field tabs: the Extra content and Extra content 2 are displayed in the backend admin article edit page, which is great. But we also need to let regular edit their article and enter values in custom fields under those two tabs. Any idea how to achieve this?
I tried a couple of other sites posting the solution of adding custom fields in article, such as Rating region described in the site:
https://docs.joomla.org/Adding_custom_fields_to_the_article_component
I was not able to make the Rating tab displayed in the front end article edit page neither.
I tried the fieldattach, it does supports custom field tab ( which is the group name of custom field), the list field type only contains static values, we have to define fieldset and field type through xml file.
Any help is greatly appreciated.
I just finished writing a couple pluginsto do this similar thing. I wrote my own plugin to add the extra fields - but it looks like the one you've already used is very similar.
I had a really hard time figuring out how to add the fields for frontend editing as well. But I finally figured it out.
First, you're going to need to copy the com_content form edit.php into a template override (/templates/your_template_name/html/com_content/form/edit.php).
In that file, add the extra fields you have. You'll need the name of the field that you put in the xml file for your plugin you already have. Add them right before/after the fields that are already in the file, that you want your fields to appear before/after. Example:
<!-- CUSTOM begin custom fields -->
<?php echo $this->form->renderField('video_url', 'attribs'); ?>
add all your fields in there - replacing 'video_url' with your own field name. The plugin you already have already saved these fields to the 'attribs' part of the article, so you can leave that there.
The plugin that I used to create the fields for the backend is a really simple one based off of this tutorial https://zunostudios.com/blog/development/203-how-to-add-custom-fields-to-articles-in-joomla
What I'd suggest is to go ahead and create that plugin too. Except in the zfields.php file, change "$app->isAdmin()" to "$app->isSite()" - make sure the xml files have the same names as your other plugin xml files, so they save to the same place, and you're done. The fields will show up on the frontend edit form now.
What I'd really recommend is to get rid of the Aixeena plugin, and just make that easy plugin using the tutorial above - it's super easy. When you make it, duplicate the "if ($app->isAdmin())" section, copy it right below it, and change "isAdmin" to "isSite" - and now you've got the entire thing, all your custom fields, both frontend and backend, all in one place. Now just do the edit.php template override, and you'll have them displayed in both the front and backend. I hope that helps - if you need I can upload more example code.
I need to create a way for users to enter recipe information into a wordpress page that can be displayed globally, on their buddypress user page, import/export based on a defined xml standard and accept reviews for each recipe. In one example the user would be able to enter more than one type of ingredient (i.e. tomatoes) with each item having the same level of detailed fields yet when exported to xml, each tomato would have its own <tomato> tags. Hope that makes sense.
My question is should I build a custom plugin or can custom post types work? If a custom plugin would provide the best solution, can you suggest reading material that would put me on the best path to create such a solution?
In that case, custom post types would work just fine. The Types plugin can automate a good part of it, including the admin interface to edit your recipes.
You could define a new taxonomy for ingredients.