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.
Related
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 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.
I am using wordpress to make a site which has job posts, and I want to know the best way to go about storing company details, as each job post must be linked to a company.
Normally I would have just set up a companies table in my database, and put a company ID within each job post, then joined to get company details.
However I have often come across the idea that it's not always the best option in Wordpress development to create new tables (such as here). Instead I would be better using custom post types.
But how would this work to store company details? Would it be right to create a custom post type for companies, and then add a new post for each company? And then use custom fields to store data about each?
Or would I be best off creating new database tables? What is better and why?
I suppose it is the best to use custom post types with post meta in conjuction with meta boxes. This way, you will be able to manage in ease your companies, and yet, you will be able to operate custom queries on companies via the WP_Query class.
Currently I am building a business directory for a my client, so I decide to use the custom post types because of flexibility. Also I made a custom script for managing company information in conjuction with post meta.
Take a look in the screen shot to undestraint what I mean :
Note that whenever I like to add new data to companies, I am free to just add some extra meta boxes, and then save the extra data as meta data for the post. This way is matter of minutes to extend a standart data entity.
What you need:
http://codex.wordpress.org/Post_Types
http://codex.wordpress.org/Function_Reference/add_meta_box
http://codex.wordpress.org/Function_Reference/register_taxonomy (optionaly)
http://codex.wordpress.org/Function_Reference/get_post_meta
http://codex.wordpress.org/Function_Reference/add_post_meta
I hope you this will help you :)
Create an Custom post type
add the custom fields to that custom post type for different fields you need,
There is no need of creating table manually,
http://wordpress.org/plugins/custom-post-type-ui/
http://wordpress.org/plugins/advanced-custom-fields/
and you can apply the sorting on some custom field you added to the post type,
I'm working on a Wordpress website that uses an external system to sell tickets. This ticket system provides a WordPress plugin that automatically creates and updates two new WordPress database tables: events and shows. That's great, but that's all this plugin does.
I have used the Database Browser plugin to test if the database tables created by the ticket system plugin were there and that was the case. I can see all the data there too. So far so good.
I now need to create custom post types (events and shows) with custom fields using the data from these database tables. I've searched, but I can't seem to find out how to create custom post types that pull their data from existing database tables.
Maybe I'm looking at this all wrong. Any help to point me in the right direction?
To create custom post refer this http://codex.wordpress.org/Post_Types#Custom_Post_Types
And use this plugin to create custom field http://wordpress.org/plugins/advanced-custom-fields/
i'm assuming you realise that you'll need to write code to query db...there are no plugins to query a db (that i know of).
it also sounds like you are going to duplicate data ie pull data from custom table events and shows, then add to this data to custom fields. i'm not sure this is the best approach.
also, if data in these custom tables change, will it be reflected in your custom fields data?
have i assumed too much? let me know.
To query db, use the wp class wpdb. I havent really used it but it has enough features to do what you want.
acf plugin has already been mentioned. custom post type ui plugin is easy for creating custom post types with no code. it even prints out the actual code for you so you can copy it, place in functions.php, then disable plugin, nice.
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.