I am building a custom post type (CPT) that requires a form that users may choose to submit. Regardless, I want any user to be able to see the current summation of the results. This is similar to how to codex article on AJAX says WordPress uses it..
"Several themes and plugins also use Ajax; for instance, some post rating plugins use Ajax to store the visitor's rating in the database and then display an updated average rating." - http://codex.wordpress.org/AJAX
How can I create an element that shows an average rating from user inputs on a CPT entry?
Related
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.
I have set up my WordPress plugin using a boilerplate. I have created a custom post type for my plugin. This is where I am at.
Where I am trying to go..
I would like to be able to create post that I have made. It is a reports Post. So in the create, I would like to customize the user interface. I want to be able to populate the options based on an external api call. One selection will populate the next selection using another external api call based on what it returned.
Then create the post.
When clicking on the post I would like to be able to use the metadata/data that came from the creation of the post type to make several api calls and populate a spreadsheet that will be displayed on the page.
I have been looking for tutorials for this and have not been able to find any. I have looked over the wp plugin development handbook and do not see a clear picture on how I can do this.
Is it possible to implement this way or should I try to make everything custom (which will be a headache especially when trying to comply to the rules, this is something I want to publish to the wordpress plugin repository eventually).
I would also like this to have a similar functionality on the front end.
Here is the process I would like the user to have.
Custom Reports page loads
-> lists all of the reports created and has a button to create a new report
-> create new report page has drop down lists. The first drop down list has x amount of options that are populated using an external api with a header that has the users credentials within it, the user selects one option. The next dropdown list is populated by an api get request using the selection from the first dropdown list. The next dropdown list is populated using an external api get request's response from the selection from the second dropdown list and so on..
-> would like to apply filters but that piece can come later
-> The user generates the report
->Then the user saves the report
When clicking on a report within the reports page, a report will be generated using the saved selections from the create report. This generation will be handled by api calls using the selections as headers. The response will then be parsed through and filled into a spreadsheet that will be displayed for the user.
The user can then export the report into a pdf or csv file.
My main question right now is there a way to implement this type of logic using custom post types within wordpress?
I have replaced my entity with Blog to explain better.
I have the following route:
Route::get('/blog-category', 'BlogController#showBlogCategory')
which shows a form with a dropdown of different blog categories and some other input fields related to the category
The form POSTs to the following:
Route::post('/blog-details', 'BlogController#showBlogDetails')
Here I validate the request the form and return back if there is an invalid blog category or if it is missing
This method is called showBlogDetails because the category and the other fields are passed on to the next view return view('blog-details', compact('blogCategoryData'))
In this view there is a form to fill in the rest of the blog details.
Both the blogCategoryData (each data has a hidden input field) and the blog details are POSTed to the following route:
Route::post('/blog-store', 'BlogController#store')
This is also validated using a Request but if it fails it tries to go back, which it can't do as only POST is allowed to get there.
I need the blog category fields before I can show the blog details and a Blog cannot be created without either stuff so I can't temporarily create one either.
This flow of selecting/filling in blog category fields and then entering details is a requirement so has to be done in that order, in 2 different pages.
So currently it is:
GET -> POST (validate) -> POST (validate)
What is the best way around this or how would I make my current flow work?
one way is to use javascript and of course ajax to fetch blog data and show corresponding section. first the page only shows categories drop down box. after changing that to a correct category page makes an ajax request and fetches data. then replaces it in a hidden 'div' and shows it.
another way is to bring replace the categories box in the previous page.
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've been trying to find a solution to this, but haven't had a whole lot of luck.
I need to give the user control over which posts are being displayed on the homepage via selectboxes. Essentialy, a 'filter by' (list of categories) and a 'sort by' (date, name and a few other custom fields).
Is there anyway to do this and have the loop refresh dynamically?
Thanks!
Z
If you want a non-coding way to do it you could use the Types & Views plugin: http://wp-types.com/
Otherwise you'll need to use javascript or jQuery to trigger an update after the user selects the categories and other criteria. Something like a submit button that triggers an ajax post of the criteria selected which then retrieves the requested posts and updates the page content.