WordPress Training: Vanishing Content

25 Feb

This is an issue I helped a fellow blogger out recently with content that she was trying to embed in a post in her blog, but for some reason it was not appearing in her post.

I had her send me the embed code and took a look at the code. Here’s a sample:

The code above poses a few issues for WordPress as there are a few things we have to take into account.

Your WordPress theme will have a layout for posts defined and the above code adds in a couple of divisions which are identified by the <div> tags. The div tags really aren’t necessary to display the video inside the post, and as such, we will remove them.

Once we remove them, you are left with the embed code below:

Now the code above has some issues with it as well, as your WordPress theme should be the one determining where the video sits in your post and what size it is. So in the code where you see style= is modifying the display of the video within the post.

What we need to do next is remove everything from the style except for the height and width.

 

The code above is now what we’re left with. 100% width means that the content will fill the available width of the post. Height can’t be 100% as it just doesn’t work 90% of the time. So for height I just picked an arbitrary width of 500 pixels wide but really this can be almost any number.

The product of the code above is below:

and there you have it! A working video!

Learning PHP: Setting Up an Environment

19 Feb

When I started writing these tutorials, I completely omitted the fact that you’ll need a web server running PHP to see the result of the code I’ve been providing. My bad!

Fortunately there’s a dead simple way to get going without any real knowledge of servers or hosting packages. Let’s get started.

First we’re going to head over toย download WAMPServer. The download should start shortly.

WAMP Download Screen Shot

It’s a farily large download, so it may take a few minutes for you to get the installer downloaded.

The installer doesn’t require any input from you while you’re installing it so simply click through the different steps of the installer until it begins installing the software, and then just let it do its thing.

WAMP Installer Running

The installer will ask you if you want to use a different browser than Internet Explorer this is up to you. If you select yes, you will have to point it to the browser you want it to use as the default. If you select no, it will use Internet Explorer as the default browser. The same will be asked of you for notepad. You can select NO for both options as they are not really important.

Now you should have WAMP server installed. You can click start and run WAMPServer. You should see an icon in the lower right hand corner of your screen like the screen shot below.

Finally we can test that our server is up and running by visiting LocalHost at (http://localhost). You should be presented with the page below.

Now we are going to go into our WAMP www folder and empty it out.

C:\wamp64\www

Remove everything in this folder. From now on, any PHP file we create, we will save in this directory. Once saved there, you can access the file by visiting http://localhost/NameOfFile.php

I’ve copied our lessons into my www folder and now if I visit http://localhost/Lesson2.php I can now see the result of our PHP Math.

 

As always if things don’t go as planned or you have any questions, please leave a comment and we will get you sorted out!

Until next time!

Learning PHP: Some Basic Math

19 Feb

Welcome back!

The next step we’re going to take with PHP is to get it performing some basic math operations for us. PHP easily makes short work of even the most complicated math work, but you need to know how to write it.

The example below will step you through the basic operations in math.

Try them out for yourself and see how you get on!

If you have any questions, please leave a comment below and I’ll get you sorted out!

Learning PHP: The Intro

18 Feb

Hello and welcome to my little PHP tutorials. These posts are meant to help people learn and understand how to use PHP. I feel like a lot of people think that coding is complicated and hard to learn but if they only knew just how simple it can be, more people would give it a try. These posts are not going to drone on about useless stuff that you can read in the PHP Documentation, but will be simple, practicle examples that you can use. Let’s get started, shall we?

Creating a PHP File

PHP files can be created using something as simple as notepad or as advanced as PHP Storm. Depending on your budget, find a tool that’s suitable for you to write code in. Here are some free software suites to make writing code a bit easier:

Personally I’m partial to NetBeans but that’s only because that is what I got started on.

Here are the steps to create your very first PHP file using nothing more than Notepad::

  1. Open notepad.
  2. Write your opening PHP tag
  3. Write some hello world code.
  4. Close your PHP tag.
  5. Click file -> Save As.
  6. Name your file. Don’t forget to add the .php at the end of the file name.
  7. In the drop down called “Save as type” select all files.
  8. Select where you’d like to save the file.
  9. Click save.

Once these steps are completed, you’ve written your very first batch of PHP which should look something like the code below.

Next on the agenda, we will make PHP do some basic math. Catch you on the next post how bow dah?