Interaction between PHP and WordPress

Does WordPress really have interaction with PHP?

WordPress is a content management system that very heavily depends on PHP programming language. They interact with each other in every step. If you want to follow this interaction between wordpress and PHP, then you must have a little bit working knowledge of PHP. To understand this interaction between them, you need to understand few PHP concepts first. Specially conditionals and loops, functions, array and finally classes and objects.

Few words for PHP and WordPress developers

Do you want to become a successful PHP and wordpress developer – all together? if that so, then this series of tutorials are for you. The first thing you need to understand is the relation and interaction between PHP and WordPress. How PHP and WordPress interact with each other? What is the relation? What PHP topics you should learn?
You may consult my PHP Articlesto get an idea.
Interaction between php and wordpress//embedr.flickr.com/assets/client-code.js

Should I be an expert in PHP?

To answer that briefly in the first paragraph I should say, you need not master PHP to handle wordpress efficiently. Yes, it’s always good to learn and dig deep into the subject but your primary concern is WordPress. You want to master WordPress. And to that you need to learn few PHP things first.
For the next big jump, you need to dig deep in PHP also. And that will always remain a plus for your web development preparation. You may read some Advanced PHP 7 Articlesin this regard.

The first interaction between PHP and WordPress.

Consider a PHP array and try to figure out how it comes to help when you build up a customized wordpress page. An output of array follows first where I have used few names. To show their interaction I will later show you how wordpress categories can be produced through an array.

Array
(
[0] => Mona
[1] => Babu
[2] => Pota
[3] => Gopal
[4] => Array
(
[0] => Buddhu
[1] => Tutul
[2] => Tapas
)

)
Next we’ll see the code:
//after php 5.3
$frienfds = ["Mona",
"Babu",
"Pota",
"Gopal",
["Buddhu",
"Tutul",
"Tapas"
]
];

Can you associate this type of array with any wordpress code you’ve seen so far? Actually in real life of using wordpress we can use categories in place of names.
In the next wordpress example we’ve just done that to prove thier interaction.

Let us consider a wordpress array this time.

In this wordpress array we try to make sure few things first. In the ‘key’ part we’ve kept the wordpress key properties and in the value part we’ve set the values.

$args = array(
'taxonomy' => 'category',
'orderby' => 'name',
'show_count' => 3,
'pad_counts' => 0,
'hierarchical' => 1,
'title_li' => 'Categories'
);

wp_list_categories( $args );

 

This will give us a nice output of all our categories we’ve set so far for our wordpress site. The positive side of this usage is it will automatically update when you add more categories. Not only that, it’ll also automatically manipulate the posts from every category.
We can explain it this way.
Whenever you write a post, it may be assumed that you’ve done some research and set your categories accordingly.

Consider the output

Categories
general (1)
php (1)
wordpress (1)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s