Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Handling standard pages

From: Dreamweaver and WordPress: Building Sites

Video: Handling standard pages

Just because you're creating a WordPress- driven site, it doesn't mean that every page has to contain user-contributed content. There are often times when the client requires pages that are expressly outside the content contributor's reach. In this video, I'm going to describe a couple of ways to build such pages. The first technique takes a completely developer-created page and converts it to be theme-compatible, and it takes just a few lines of code. Let me demo the method with a dummy legal disclaimer page, one that would almost never be touched by a content contributor.

Handling standard pages

Just because you're creating a WordPress- driven site, it doesn't mean that every page has to contain user-contributed content. There are often times when the client requires pages that are expressly outside the content contributor's reach. In this video, I'm going to describe a couple of ways to build such pages. The first technique takes a completely developer-created page and converts it to be theme-compatible, and it takes just a few lines of code. Let me demo the method with a dummy legal disclaimer page, one that would almost never be touched by a content contributor.

So I'll go up to File > Open. And I'm going to navigate to my exercise files, in Chapter 1, folder 01_02, and open up the disclaimer.php page that you see here. Now, it says it's a PHP page, but if we take a look at the code, you can see that it's really just a standard HTML page here. That's fine. I saved it as a PHP page so that we could take advantage of the processing power of PHP in our WordPress application.

So I'm going to remove all the code up top, up to, and including, the opening body tag, so I'll be left with just the content. And then also I'm going to remove the closing body and HTML tags, so we have nothing but pure content on this page. Now, let's go up to the top of the page, make a little space, and then I will put in a PHP code block, and within this code block, I'm going to put in two lines of code.

The first will include a certain PHP file that will start the whole WordPress ball rolling. So type in require, open and close parentheses, and then within those, we'll put a pair of single quotes, and then the file name, which is wp-blog-header.php. Now after your last parenthesis, put a semicolon and hit Return. The require function may look familiar. Let's flip over to my index.php page and go into Code view.

This is the opening page, and as you can see, we have the same basic file. Now, I'm going to save mine in the site root, so I don't really need any additional path information here. So let's enter in our second line of code, which is get_header. This function will get the header of our theme. Now, we need to put some corresponding PHP code down at the bottom to get the footer.

Okay, that's actually all the code you need. I'm going to save this, as I said, in the site root, and to do that, I'll choose Save As, click Site Root from my Save As dialog box, and we'll leave it as disclaimer. Click Save. Co not click update links, click No. Let's get rid of the old version of disclaimer. Now, let's switch over to Design view and then enter into Live view, and there you can see my content now with the complete framing, including navigation, header and footer of the theme.

So visually the content fits in perfectly with the rest of the WordPress theme pages. I'll go back over to index.php, enter into Design view and then Live view, and as you can see, it's identical for the header and the background, as well as the footer down below. One of the great things about this technique is should you ever update or even completely change the theme, those changes will be automatically applied. However, there is a downside to this technique.

Because the pages are created outside of the WordPress database system, you can't search for them with a built-in Search function. Also, you'll need to link to any pages developed this way with absolute URLs, including the site's web address. Another way to go, and stay within the WordPress system, avoids both of these pitfalls, is to create pages that allows only WordPress users with certain roles to modify. WordPress includes five different roles.

Let's flip back over to the dashboard and I can show you what those are. You can see all the roles if you choose Users > Add New, and then at the very bottom, you'll see a line for Role. And by default, new users are offered a Subscriber role, but there is also Administrator, Editor, Author, and Contributor roles. Honestly, by default, user roles in WordPress aren't extremely useful; however, they do lay a foundation for a number of killer plug-ins that can really enhance the feature.

One of my favorites is called Role Scoper by Kevin Behrens. This free plug-in goes a long way towards making WordPress a more full-fledged CMS by enabling you to set access permissions for posts and pages based on role. Let me show you how it works. We'll go back to our Dashboard, go to Plugins > Add New, and in the Search Plugin field, type in Role Scoper, click Search Plugins, and it will be returned at the top of the list.

I'm going to go ahead and install now. Click OK when you're asked if you sure you want to install it. The installation is pretty quick, and then click Activate Plugin. Now, keep an eye on the left-hand column and if you notice, the menu options changed significantly when the plug-in was activated. Some of the new settings as you'll find are under Users, where now we have a Role Groups option, under Restrictions, that will allow you to set restrictions on categories, navigation menus, list categories, posts and pages and an entire new category on roles, with a ton of options.

For the purposes of our demo, we can leave all the settings at their default, and let's quickly create a new disclaimer page. So I'll go up to Pages > Add New, give it a title of Disclaimer, as we did before, and now I'm going to flip back to Dreamweaver and pick up that Lorem Ipsum text here. I'll copy that and back to WordPress, paste that in. Now, if you scroll down, you'll see some additional options have been added under the page editor.

You can restrict the readers to this. We don't want to do that, so I'm just going to collapse that option. Contributors, we definitely want to restrict this here. So I'll choose Restrict for page. And just in case there are some sub-pages that come off of this, probably we want to restrict that as well. So we don't want anyone else to change it except administrators. So we're going to make our eligible groups here and you'll notice that these are the same roles that WordPress set up. We want only the administrators to be able to contribute to this item. All right! Contributors is done. I'll collapse that.

Now Editors, I'm going to go ahead and restrict the page and sub-pages and again, make the administrator eligible. Now, we have no associates, so I can leave that alone, and let's go back up and publish our page now. Now, because I'm logged in as an administrator, if I go to Pages, I'll find my Disclaimer page here, and I can view it, I can edit it; all that's available to me.

Show transcript

This video is part of

Image for Dreamweaver and WordPress: Building Sites
Dreamweaver and WordPress: Building Sites

21 video lessons · 16491 viewers

Joseph Lowery
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Dreamweaver and WordPress: Building Sites.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.