I am an fairly experienced C/C++/C#/Oracle SQL developer who now has time on his hands to look into some web development. I am relatively new to HTML/CSS but I have some experience with WordPress so I have used that as a starting point for a basic site with the intention of adding my own PHP/mySQL code.
So far I have discovered that I can create my own WordPress template and page but adding a form to that proved very difficult as it would not call back it’s own page correctly. So then I discovered that putting that code into a plugin was very easy worked correctly.
My question is: Is this the correct approach?
Is it quite acceptable to write custom code in plugins or is there a better way to do this?
The nature of the site will require a quantity of database code and customer forms and also a Google Maps API.
I’m OK either way, I just want to find out what other people use and hopefully save myself some wasted effort.
I have just started with Wordpress and think plugins are the way to go. The people who write the plugins hopefully know the way Wordpress works and you will have to find your way around it
Word press is a lot more user friendly now than it used to be and as long as the developer keeps the plugins up to date all should be OK.
There are also plugins for Google maps. In fact there is probably a plugin for everything you want to do but it can be a bit costly buying lots of them!
Saying that I normally hand code as I like to be in control and Wordpress pages are huge. The only reason I am using Wordpress now is it is a site I have inherited.
Thanks for the reply, I have no problem using other peoples plugins but what I meant was; is putting my custom PHP code into a plugin the “normal” way of adding functionality to an otherwise empty WordPress page? In the example above it appeared to be the only way to make a form work correctly.
Does one simply create a new plugin for the code required on each page?
My intention is to use the basic functionality provided by WordPress (instead of writing the whole site myself) and then add my own PHP-based pages for the additional code I require.
Believe me, you want to not hack core files.
With a combination of child themes to customize the “look”
and plugins to customize the “feel”
you should be able to do just about anything.
There can be some overlap - themes can have functions and plugins can output DOM elements - but no matter how you organize things, keeping your customizations out of the core code will save you from a lot grief.
The correct way to implement a feature is with plugin. Especially if you aren’t using a custom theme.
This was not always the case. For example some years ago (even still today) you could download a theme which would come with a ton of extra features but all those features would be embedded in code throughout the theme itself. This created a lot of lock-in to the theme. If users wanted a new theme, entire huge chunks of data and functionality would be lost because it was embedded as part of the previous theme.
The moral of the story is, if you are building some code that could be useful no matter what theme you use, then put it in a plugin.
Any code that is very directly related to just the theme itself that doesn’t really make sense as usable with other themes, keep in the theme folder.
The benefit of putting code in a plugin is that you can reuse it as needed pretty easy when you build more sites. If you make it generic enough, you could eventually distribute it as a standalone tool that others could use.
Thanks for this reply, this is exactly what I was hoping for.
I am putting my own code into a plugin but I was not sure if this was the usual way of doing things.
Glad to hear I am on the right track!
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.