I'm trying to create a plugin in wordpress that allows you to age restrict certain posts and pages but not others. I looked for a plugin that does this and couldn't find one. I've got all the coding covered except I can't figure out how to instruct wordpress to save the state of the checkbox as data associated with that post or page. I dissected a couple of plugins that have similar functionality but am mystified by how their code works and it breaks when I try to modify it for my use.
Can someone point me to a tutorial that explains how data gets saved from the post edit page and how to access that data later?
check out post meta-data :
http://codex.wordpress.org/Custom_Fields
The basic idea is WP allows you to add additional fields to a post, and then retrieve it during the loop. Just use this field to test against at render-time and display alternate content, should (in this case) your post be restricted.
The codex is pretty thorough on the subject, and I'm sure google can fill in the gaps -
Hope that helps
Related
I would like to implement a Custom Search Plugin for Joomla 3.5.1. I am new to Joomla and still busy getting my feet together.
I recently implemented a plugin that adds custom/extra fields (5 fields, free text inputs) to an article in Joomla 3.5.1. I followed their tutorial on how to get this right and so far so good. This plugin saves the extra/custom fields in the #__user_profiles table as per their tutorial. I could obviously save it to a different table but since I am learning, I kept it simple. This plugin works perfectly and I can capture the extra fields and saves successfully and the data is saved along with the article id being edited/created.
My next task is to create another site/front-end "search" (or smart search) plugin. This plugin must group the 4 field's values and provide them to the user in the front-end as selects/dropdowns.
Is there someone that can give me a lead on how I can archive this. Must I implement it as a search or smart search plugin? Is it even possible to archive what I am trying to archive?
This search plugin will only appear on one page but that I know I can config correctly once I've a plugin. Once user searches, the system must post back the selected options and I will search the "#__user_profiles" for any matching profile_key vs profile_value and collect all user_id (article_id) and get these articles from contents table and return this list of articles to the front-end as search results. Anyone can help me into the right direction?
I tried their tutorial of creating a search plugin but I seem lost, mostly I don't know how to dynamically provide my selects/dropdowns with that info saved in the #__user_profiles table.
Please assist in anyway possible...
I don't think that this might be done without modifying core 'search' task. My advise is to advise search view and include extra filtering, then write own 'search' task which allow you to read this data and provide additional results.
By writing just search plugin you can only extend search results by data which is stored outside default Joomla! tables but nothing more.
After providing an event calender with PHP/MySQL/HTML/CSS I want to use Wordpress for that project from now on. Account and data management will remain outside of wordpress scope.
My best idea so far is to populate the posts (or pages) entirely from the already existing db. The URLs would be created by apache's rewrite engine.
To use one post and populate just the content would lead to really bad SEO.
So I want to create (virtually) unique posts populated entirely from the db. Extensive research on that topic brought up nothing usable so far. Maybe someone could point me in the right direction?
Preferences:
using mod rewrite to create the pages urls from event /ID/title rather than using the timestamps to create posts
keeping the data editable via external admin panel (no copying into WP-DB)
head data of post / page must be populated from db, e.g. title, author, timestamp etc.
Suggestions would be much appreciated, thanks in advance.
Have you tried the plugin WP All import. It creates unique post such are car listing etc based on the external DB. I also allows you to style and format your post.
https://wordpress.org/plugins/wp-all-import/
Alright I am completely lost on how to do this so I am just going to throw the question out there and hope somebody can help me in some way or another.
WordPress offers the option to create custom Taxonomies so I got the idea of pulling something out of my hat and creating a custom content section apart from the content section wordpress currently offers.
The website shown above is the only website I have been able to find which currently does this and is on a WordPress platform, as you can see they have the SoundCloud audio player pushed over to one side with the actual content placed to the other side creating that flawless look.
I guess the question here is how can I turn <?php the_content(); ?> into something completely custom pulling from a completely different form in the back end so the same information is not shared.
There are numerous ways to achieve what you want.
Shortcodes
Custom page templates
Custom meta fields to store values like the soundcloud embed url, to afterwards use it in your code.
You can always also enter HTML in the page editor, but for obvious reasons not recommended.
Custom post types allow you to define a new type of content. It will have its own section in admin where you add and edit data separate from normal Wordpress posts. It can have its own templates allowing different layouts, and you can set up custom fields so that it can store different data.
I also recommend taking a look at the Pods Framework. This plugin allows you to define custom content types very easily in the admin interface. You can set up all your fields and data types from there. All that's required then is to create the templates to make it look nice.
The nice thing about these approaches is that while the data is kept separate from standard Wordpress posts, you still have the same familiar UI, so it's easy for none-technical users to update the content.
I followed the below tutorials in order to create a custom post type with custom fields.
https://www.youtube.com/watch?v=-r1b0wA98Ew
https://www.youtube.com/watch?v=6URWfMTsWPo
This worked great and I added lots of data using the forms I'd created and had the data displaying on the front end of the website.
A week ago, the custom post type disappeared from the Admin Menu but the the data seems to be intact from the front-end point of view. I posted a message in the CPT UI wordpress forum and got told to simply re-add the post type and re-link the data back up.
My question is HOW do I re-link the data back up? I have re-added the Custom Post type so its ls listed in the admin menu, but I need to be able to edit the custom posts I have already added. Can anyone help? Not getting much help from the Wordpress forum. Thanks
AS the data is intact in the front end it means the entries are still in database and nothing is lost.
It is correct way to just re-add the missing post-type and WordPress will now automatically re-link/re-connect your existing data, since WordPress is storing custom post type in the wp_posts table with post_type field value to your user-defined value.
Just make sure that the post-type name is same as you used earlier because slight mistake in spelling will lead to data not displayed in admin panel as expected.
You can also post further details which would be helpful to get actual problem found out.
#leetee this has 50/50 chance, experimental and since there is no way to reproduce this behaviour; try exporting your custom post types by using Tools -> Export and then see if you could Import them into a fresh WP install...
I'm having major problems with this. Basically, I need to add a "url" field to the event management plugin with wordpress. My client wants to be able to add a url to their event so it can be clicked and viewed for more information on the event. I've looked through everything and im having problems understanding the wordpress file structure. I tried to add my own field to the event editor, database and front end but i dont know where wordpress posts the data to so i cant receive the variable. If i could get the variable, i could probably figure out how to use $wpdb relatively simply. but for that matter, i dont know where i should use that. where is the file that makes all those calls? i shouldnt have a problem getting the data from the database.
Edit
My problem, as described, was solved by installing another plugin called PODS. the only solution to adding functionality to a plugin, as in other fields, is to write your own plugin (as far as im aware). PODS solved my problem. It allowed me to add another field to the front of the event management form and saved it to the database. I still had to retrieve it from the database and display it on the front myself with php, but it was a much easier task than i expected it to be. If anybody wants to add extra fields to a plugin in wordpress, PODS is what i'd suggest. It's also free.