Click to See Complete Forum and Search --> : wordpress; inserting code


anothen
12-13-2010, 06:49 PM
I just discovered Wordpress and trying
it out. I want to put some of my own
PHP or Javascript code in, but I can't
seem to find any way of doing it.
Their documentation don't seem to
help much, unless I'm just missing
it somewhere.
It seems I need to re-write my code
as a "plug-in" and install it and activate
it. Is this correct? and if so, is there
a place to find how to do this?

aj_nsc
12-13-2010, 08:19 PM
A wordpress site is just a bunch of "template" files that consist of php and html. Stick your code in wherever you want.

No need to create a plugin to put some simple JS/PHP code in a wordpress site.

anothen
12-13-2010, 09:14 PM
A wordpress site is just a bunch of "template" files that consist of php and html. Stick your code in wherever you want.

No need to create a plugin to put some simple JS/PHP code in a wordpress site.
That's what I thought, but it just don't
seem that easy.

aj_nsc
12-14-2010, 05:45 PM
Trust me, it is :)

Are you have trouble with any specific task that you're trying to accomplish?

anothen
12-14-2010, 06:00 PM
Well, I tried from several different
angles, I found the .php file
in which I could add the code,
but my code also has .css and
.js files. and I was hoping
to find a different way first.

I thought of just adding a .php
file in the folder, but I need
to find a way for it to access
it. The folder is ".. wordpress/wp-content/
themes/plain-fields .
There are a number of .php files
like: " catagory.php , header.php ,
footer.php and page.php "
however, I need to find the
control file that will allow my .php
file.

I've spent hours studying the
plugins documentation, but
there's not much about how
to develop my own, unless I'm
just missing it somewhere.

anothen
12-14-2010, 06:14 PM
I looked through the " .. index.php .. "
in the ".. //plain-fields/ " folder
but it is filled with php functions
that I would need to research
to find out what they do,
along with " div class " 's
that I would need to research
and find out what they do.

It sure seems like way too much
work, just to add a file
in the folder.

Am I just trying too hard or
is there a more simple approach?

aj_nsc
12-14-2010, 07:05 PM
okay, well at least it seems like you're in the right place. You're website is located in your theme folder, which, according to you is wp-content/themes/plain-fields/

Wordpress uses what are called "template" files. header.php is always the first file loaded on your site and footer.php is always the last. The content depends on what template you use (go to your wordpress back end and click "Pages" and "Add New" and in a meta box on the right of the textarea where you write the content you'll see "Page Attributes" where you can specify the template).

Some of the are things like category.php, single.php archive.php, etc. If you don't specify a template, then you can bet the your site is being built through the index.php file in your theme folder.

So basically, here's what a generic wordpress site is made up of:
header.php
index.php
footer.php

If you want to add any code, then add it to these files.

If you'd rather put your code in a separate file, then I'd recommend making a folder - something like includes - inside the theme folder and putting your php code in that file. Likewise, if you would like to add your own css files, create a css folder, create your own javascript files, create a js folder and put your files in their respective folders (this is just what I do to keep everything neat).

Then, include them in your site where you want. If you have a js file called validate.js and you want to put it before your closing body tag, then you'd open up footer.php in your theme folder and put


<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/validate.js"></script>


and voila! You've put your own Javascript in your wordpress site.

If you wanted to include some php code in the body, then put this in index.php (or whatever template file you are using):


<?php include('includes/myscript.php'); ?>


As for your last post, in order to use Wordpress to its best capacity, you do need to research it, and while it may seem daunting, the wordpress codex (http://codex.wordpress.org/Main_Page) provides really good documentation and, once you know your way around wordpress, it's can be used as an extremely powerful CMS for not just blogs, but just about any type of site you can dream up.

Good luck!

anothen
12-14-2010, 07:12 PM
Thx aj_nsc

I finally did find documentation
that will help to develop
plug-in's, and I think that
may be the way I need to
go because I have a friend
that uses WordPress that
would like to use my program
also.

I will need to go through hoops,
but I think it's worth it.

aj_nsc
12-14-2010, 08:22 PM
Fine, but I just want to make it obvious that building a plugin is not for people whom don't understand wordpress. It is not a trivial task and I think you should probably become more familiar with the system before you build a plugin.

I've customized dozens of wordpress installations in all sorts of ways - both backend and frontend - and I have a total of 0 plugins to my credit. I think you got it in your head that in order to do what you want, you need to make a plugin, that is far from the case.

anothen
12-14-2010, 08:37 PM
Fine, but I just want to make it obvious that building a plugin is not for people whom don't understand wordpress. It is not a trivial task and I think you should probably become more familiar with the system before you build a plugin.

I've customized dozens of wordpress installations in all sorts of ways - both backend and frontend - and I have a total of 0 plugins to my credit. I think you got it in your head that in order to do what you want, you need to make a plugin, that is far from the case.

Well, further research, I think you're right.
I'm discovering that plugins are hook
and filter types of programs.
I did find some documentation about
adding pages:

http://codex.wordpress.org/Pages

This might be what I'm needing.
I'll first try to make a page with
some simple code and go from there.

All I really want to do is take:

Currency Rank (http://www.anothenservices.com/PHP/trading/jscrpt_ranking.html)

and place it on a W-P page.
However, it contains head, body,
with .css javascript and also has capability
to use cookies saving the information
to a separate .php page.

It's really designed to have it's own
html page.

anothen
12-14-2010, 09:49 PM
Okay, it's taking some work, but
I think I'm getting the general
idea.
Everything is in modules like
head contains everything
that would normally be in the
html head and the other
php files contain other parts
of the displayed page.
I just created the "snarfer"
example page and was
able to run the program
there.
It is easier than what I was
making it out to be. I just
needed to study through
the admin pages a little further.
I just discovered that I can
edit pages from the Appearance/
editor and I can edit all of the
available .php files and add
my own page with my own
customization.

vjackcon
01-13-2011, 04:58 AM
Hi to all., i have one doubt, how to insert RSS feed in my wordpress blog?

web application development (http://www.benivolent.com/web-application-developments-company.html) | facebook applications development (http://benivolent.com/facebook-application-development.html)