Dreamweaver and WordPress: Core Concepts
Illustration by John Hersey

Adding dynamic data from WordPress to your web pages


Dreamweaver and WordPress: Core Concepts

with Joseph Lowery

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Video: Adding dynamic data from WordPress to your web pages

Time to bring the data from WordPress right into Dreamweaver. In this lesson, we'll show you how to make a database connection, create a record set and then add the data from that record set to your Dreamweaver page. So in Dreamweaver, let's open up a previously created file to hold our dynamic data. Now this is just a standard PHP page. It's not hooked into WordPress at all. I am going to go to File > Open and then navigate to my Desktop > Exercise Files, go down to Chapter 11, and open up 11_02. I'll open that up, and it'll come in unstyled.
Expand all | Collapse all
  1. 4m 7s
    1. Welcome
    2. Using the exercise files
      1m 54s
    3. A word about updates
      1m 15s
  2. 15m 28s
    1. Overview
      1m 51s
    2. Creating the database and the initial site
      3m 45s
    3. Configuring WordPress
      5m 54s
    4. Establishing a Dreamweaver site
      3m 58s
  3. 20m 18s
    1. Accessing dynamically related files
      4m 12s
    2. Filtering files
      4m 20s
    3. Following links
      4m 15s
    4. Employing Live Code
      2m 54s
    5. Enabling site-specific code hinting
      4m 37s
  4. 21m 8s
    1. Adding blog posts
      4m 55s
    2. Editing blog posts
      3m 20s
    3. Adding new pages
      2m 59s
    4. Including images
      6m 59s
    5. Adding videos to posts
      2m 55s
  5. 18m 12s
    1. Understanding WordPress structure
      3m 52s
    2. Activating a theme
      7m 21s
    3. Setting up a child theme
      6m 59s
  6. 1h 29m
    1. Updating the page structure and the background
      12m 53s
    2. Working with web fonts
      4m 3s
    3. Styling a header
      11m 48s
    4. Adding header functions
      7m 40s
    5. Setting up content columns
      10m 9s
    6. Changing the main content
      5m 17s
    7. Managing the content code
      4m 48s
    8. Customizing the sidebar
      10m 32s
    9. Styling search
      7m 8s
    10. Working with search text
      5m 49s
    11. Integrating the footer
      9m 40s
  7. 27m 18s
    1. Setting up media queries
      6m 12s
    2. Customizing for tablets
      12m 19s
    3. Building smartphone layouts
      8m 47s
  8. 23m 28s
    1. Working with categories and posts
      5m 31s
    2. Developing category-driven pages
      11m 22s
    3. Changing headers by category
      6m 35s
  9. 36m 32s
    1. Adding Spry accordion panels
      17m 44s
    2. Working with Spry form validation
      11m 56s
    3. Integrating jQuery functionality
      6m 52s
  10. 11m 7s
    1. Understanding WordPress plugins
      6m 20s
    2. Styling plugin output
      4m 47s
  11. 25m 44s
    1. Customizing the Dashboard
      6m 52s
    2. Working with WordPress functions
      8m 7s
    3. Including administration interactivity
      10m 45s
  12. 13m 10s
    1. Setting up the data in WordPress
      2m 17s
    2. Adding dynamic data from WordPress to your web pages
      10m 53s
  13. 11m 38s
    1. Modifying general settings
      4m 12s
    2. Setting up users
      3m 11s
    3. Restricting access to specific WordPress pages
      4m 15s
  14. 26m 38s
    1. Exporting and importing WordPress files
      7m 9s
    2. Backing up and restoring the database
      8m 10s
    3. Transferring files
      6m 3s
    4. Testing and fine-tuning
      5m 16s
  15. 18s
    1. Next steps

please wait ...
Watch the Online Video Course Dreamweaver and WordPress: Core Concepts
5h 44m Intermediate May 27, 2010 Updated Oct 23, 2012

Viewers: in countries Watching now:

In this course, author Joseph Lowery shows how to combine the utility of WordPress and the power of Adobe Dreamweaver to transition existing websites to the WordPress platform. The course demonstrates how to create new blog posts and pages, customize WordPress themes, and extend WordPress editable pages from within Dreamweaver. It also covers how to add Spry elements, add and customize plugins, and enhance WordPress-stored content with Dreamweaver's dynamic pages. Plus, a chapter on responsive design shows how you can adapt your layouts for tablets and mobile devices.

Topics include:
  • Using the Dynamically-Related Files feature in Dreamweaver to design WordPress pages
  • Applying WordPress themes
  • Customizing themes
  • Adding Spry widgets
  • Adding WordPress dynamic data
  • Populating the WordPress database
  • Publishing a WordPress site
Dreamweaver WordPress
Joseph Lowery

Adding dynamic data from WordPress to your web pages

Time to bring the data from WordPress right into Dreamweaver. In this lesson, we'll show you how to make a database connection, create a record set and then add the data from that record set to your Dreamweaver page. So in Dreamweaver, let's open up a previously created file to hold our dynamic data. Now this is just a standard PHP page. It's not hooked into WordPress at all. I am going to go to File > Open and then navigate to my Desktop > Exercise Files, go down to Chapter 11, and open up 11_02. I'll open that up, and it'll come in unstyled.

So the very first thing we are going to do is save it to the local Site Root. So choose File > Save As and then on the Save As dialog box, click Site Root and Save. Now you do not want to update the links because this is coming in with all the links intact, so click No, and there is our basic page we styled with a Exhibits header. Let me go into Live view, so you can see the full page, and it conforms to the rest of the site, not to our blog_comp.

Now the next step is to create a connection to the MySQL database used by WordPress. Now I'm going to need to open up my Database panel, but I need to drop out of Live view temporarily for that to happen. We'll click on Live view and then go to Window > Databases, and that will open up the Database panel which also has Bindings and Server Behaviors as well. We want to add a new MySQL connection. So, click on the plus sign and choose MySQL Connection. Now let's give our connection a name. I like starting with C-O-N-N, conn, and I am going to call this connExhibits.

MySQL server is localhost, my User name is Root, my Password is also root. Now that we've entered the first four fields, we can click Select. If you try to click Select before then, you won't see any databases. So click Select, and there is the databases that have been set up on my localhost. Here is roux_blog, that's the one we want, so we'll click OK. Now, it's always a good idea to test to make sure that it connects all right, and everything looks beautiful. So let's click OK once and then again to make that connection.

Now what Dreamweaver is actually doing is in the Site Root, it creates a folder called Connections and then puts a PHP page with your Connection name as the file name, so here we see connExhibits.php. Now we are ready to go to the Bindings tab. So I am going to collapse files and then click on my Bindings here, and here you can see that we have three out of the four steps already established, and we are going to complete that forth step by adding a record set, but that record set is going to employ a fairly complex bit of SQL.

So to save a little time, I have gone ahead and created that for you. I am going to open up that file from the exercise files again. So go over to File > Open, and let's head back to our Desktop > Exercise Files in Chapter 11, again 11_02, and this time open up recordset.sql. So you may look at this, and if you're not that familiar with SQL and think of it as a very complex SQL statement, it's actually relatively straightforward. Let me walk through it a little bit so you understand it better. But basically, what we are doing here is selecting a set of records, hence the name recordset.

So we want the recordset to be distinct so that there are no duplicates, and that's the keyword distinct here, and we are going to bring in the WordPress post title as well as the content. So just those two items, the title and the content, and we're bringing those in from a table called wp_posts which is pretty much self- explanatory, and then also the wp_term_relationships table is being used. Now that's the table that monitors the categories among other things and its relationship to the various posts.

So after that connection is made here in the WHERE statement, we want to make sure that we are filtering on a field called post_status listed here, and that is set to private and then also another field in the wp_term_relationships table called term_taxonomy_id, and that's going to be set to a specific value. Now just because I use this SQL statement a lot, I have this set up with a couple of question marks, but we want to replace those question marks with a certain value, and what is that value? Well, it's going to be the category number that we saw earlier, which as you might recall for me is 10.

The order of the records that is returned, which is the next and final line on the SQL statement, is set to showing the newest one first or in other words the dates descend. So I am going to select the SQL statement, copy it, and head back to my exhibits.php file where we are ready to create the recordset. So I'm in the Bindings panel, I'll choose the plus sign, and then select Recordset (Query). Now what you see on the screen here is what's known as the simple version of the Recordset. There are two different views. We want to switch to the Advanced view.

Now if you have done some database work before, and you have established another recordset where you did use Advanced view, that will come up automatically. So, I am going to call this rsExhibits. And I want to make sure that my connection is set to connExhibits, and since that's our only connection, that's what's going to happen. Now after I press Tab, it goes to the SQL field, and I can delete what's selected and paste in with a Command+V, MySQL statement. Now let's go ahead and test this by clicking the Test button here. And here you see the one record that we have, Student Exhibit, and a little bit of content there.

That's good. So click OK once and then one more time to close the Recordset. All right. We are actually ready to bring the content onto the page. So I am going to put my cursor where I want it to appear, and you have to do this in Design view, you can't do it in Live view, and I am just going to put it right after the paragraph, and I am going to expand my Recordset that you see here--let me bring the Field name over a little bit so you can see all the information-- and here you see the two fields that we brought in, post_title and post_content. We are going to insert post_title first.

So you can drag and drop it onto the screen, or if you've already positioned your cursor as I have where you wanted to go, you can select what you want and then click Insert. Now, that will come in as a standard paragraph, as you can see down here in the Tag Selector at the bottom of the screen. Let me open up my Property Inspector, and I am going to change that Format to an h2 tag. After that, I'll hit Return so after the title we'll put in the content. Now, this time I am just going to go ahead and drag that content in to show you the alternative way that you can work with this, and each time I do, you see that it lists in curly braces, and it slightly highlighted the Recordset name rsExhibits and then dot and whatever the field name is.

Okay, so there is our two bits of content. Let's save the page, and now I am going to go into Live view, and Live view works not only for CSS and PHP, but it also works for MySQL. So we can see that brings in the dynamic content, and we do have a little bit of work to do here, but that's good because it shows that up. So I am going to go ahead and create a new CSS rule in main.css. Let's go down a little bit here, and I'll put it towards the bottom, right above the @media statement for my phone.

So this will be one for mainContent and an unordered list, and that will handle any unordered lists that are encountered here. I am just going to set the margin, 0 at the top, 0 on the right, do 15 pixels on the bottom, and 20 pixels on the left. So I'll save that and then head back to Design view, and it's much better. But at the moment, this dynamic page would only show one event. So if I toggle off Live view, you can see that I just have these two bits of code here, moreover, the event that it would always show would be the most current.

Now that might work in some situations, that might be in fact exactly what you want to do, but let's say we want it to show multiple events. So what do we have to do? Well, what we need to do is wrap whatever it is we want to repeat in what's known as a Repeat Region server behavior. So I am going to add one more bit of content, and that's a horizontal rule here, and I'll put that right after my content so that we have a little bit of separation between the two. I am just going to go right to the Source Code and put my cursor there.

So instead of a paragraph tag here, I'll make this an hr tag, okay. So, we'll save that and then head back to Design view, and you can see my new horizontal rule there. So now we are ready to add a Dreamweaver server behavior. I am actually going to go back into the Split view as I found it's actually easier a lot of times to select exactly the content that you want. And in this case, what I want are these three code lines here, the h2 which has the PHP code for showing the title, the paragraph tag which has the PHP code for showing post_content, and then my horizontal rule.

With that selected, let's go over to our Server Behaviors panel where you can see certain Server Behaviors have already been added. There is our Recordset, and these are the two items that we inserted into the text. So, I'll click the Add button and choose the second option which is Repeat Region. Now when it comes up, you'll show a list of your recordsets. If we had more than one defined, it would be available to us from the list here, but we only have rsExhibits. So that's pre-selected for us. And there is two options. You can choose to show a finite number of records at a time, and it's definable, it can be 10 as the default setting is or 5 or 3, or if you want to show all the records as we do, you can choose All Records.

So then click OK and Dreamweaver will add in the necessary code, it's a PHP do-while loop. And let's go back to Design view now, and we'll turn on Live view, click Save and right now what you'll see is basic code, so we still have just one bit of content here, so you're only going to see one record. Let's go back to WordPress, and I'm going to add a new post that I'll call Spotlight Exhibit, and we have some sample content as well. And again, I am going to add in a few bullet points. Okay, we are going to do those same two things that we did before when we changed the visibility to private, so let's go over to Edit, next to Visibility, change that to Private, and click OK, and we already have our Exhibit category set up, so I'll click Exhibits and Update.

Let's head back to Dreamweaver, and I am just going to refresh the page, and now we have two exhibits listed on our Exhibit page, Spotlight Exhibit, and Student Exhibit. There is the separator and everything looks in proper date order that we had set up. So, this is really just the start of what you can do with data from a WordPress-driven database. All of the other Dreamweaver Server Behaviors are at your disposal as well.

Find answers to the most frequently asked questions about Dreamweaver and WordPress: Core Concepts .

Expand all | Collapse all
please wait ...
Q: While trying to set up a Dreamweaver site, an error occurs that says Dreamweaver cannot resolve the dynamic files because the site definition is incorrect. What is causing this? This is using WAMP on a Windows 7 computer.
A: When setting up the site in Dreamweaver and creating a local testing server, make sure to point it to the folder in c:/wamp/www/ that is being used for the site. If using the same naming convention as shown in the videos, the server folder should be pointing to C:\wamp\www\explore_ca\ and the Web URL field should read http://localhost/explore_ca/, like the picture here:

Q: How do I set the password for WAMP Server 2?
A: The WAMP server does not include a password for MySQL when first installed. You’ll need to add a password by modifying a configuration text file and set up a password in the MySQL server.
Setting a password on the MySQL server:

  1. From the Start menu, enter CMD to open the command line interface.
  2. Switch to the bin directory of your MySQL folder, installed by WAMP. For version 5.1.36 of MySQL, for example, enter cd c:\wamp\bin\mysql\mysql5.1.36\bin
    Navigate within the WAMP folder installed on your system to find the proper path.
  3.  Enter the following: mysql -u root
  4. The command line for MySQL will open with a mysql prompt like this: mysql>
  5. Enter the following:
    SET PASSWORD for 'root'@'localhost' = PASSWORD('yourPassword');
    - replace 'yourPassword' with the password you want to use. 
  6. Close the CMD window.
Setting the password in the phpMyAdmin config file:
After you change the MySQL password you will have to edit the config.inc.php file. Here's how:
  1. In Windows Explorer, navigate to C:\wamp\apps\phpmyadmin3.2.0.1 (version number may vary). 
  2. Open the file config.inc.php in Dreamweaver or another text editor.
  3. Locate the following line:
    $cfg['Servers'][$i]['password'] = '';
  4. Enter your password between the quotes; make sure the password is the same as the one you set in the MySQL server.
  5. Save the file.
  6. From the system tray icon for WAMP, choose Restart All Services.
  7. To test, choose phpMyAdmin from the WAMP system tray icon.

Q: After creating a template following the instructions in the Chapter 5 video “Creating a page template in Dreamweaver,” I am unable to select the template. In the video, the instructor’s page shows a heading of Template, with a dropdown menu, but my version shows only a dropdown labeled “Attributes,” and the newly created template does not appear. What is causing this issue?
A: This seems to be a bug in WordPress that occurs occasionally. Although a cause has yet to be determined, a possible workaround to get the Template option to appear is switch themes. Switching to the default theme and then back again to Explore_California should reveal the Template option.
Q: While following along with the instructions in the "Setting up a MySQL password for Windows," I encountered this error: MySQL said: "#1045 – Access denied for user ‘root’@’localhost’ (using password: NO)" What is causing this error?
A: This error occurs when trying to enter the MySQL monitor with a password for a user who has not set a password yet. In that case, removing the “-u root” part should resolve the problem.
Q: While following along to the chapter 2 movie "Using dynamically related files," I get an error message that reads: "Dynamically-related files could not be resolved because the site definition is not correct for this server." What is causing this error?
A: This is a known issue with Dreamweaver, and relates to the permalink settings in the WordPress installation. If the permalink setting is set to something other than the default, like “Month & Name,” for example, Dreamweaver is unable to resolve the dynamic files, and the described error will occur. Changing the permalink setting back to Default will clear the error.
Q: I am bit confused as to my need to use MAMP with a WordPress site in Dreamweaver. If I am going to use a separate commercial hosting site as my server, do I still need to use MAMP in my WordPress site?
A: MAMP is installed to provide an easy-to-use development server capable of handling MySQL and PHP on your local computer. It's also possible to set up MySQL and PHP servers separately, but it requires many more steps and is not as "user-friendly" as the described process. Your hosting server will have MySQL/PHP enabled on their servers for the remote live setup, but that doesn't have anything to do with developing and testing pages on your own computer.
Q: I can't find the file named commevents.php in the exercise files. I need it to set up an online database in the last chapter.
A: This is a file you create yourself when you first connect to a database. Refer to the "Adding WordPress dynamic data to pages" video in Chapter 7. commevents.php should appear in the Connections folder once you establish a connection.
Q:  In "Setting up a MySQL password for Windows", I'm getting the error "#1045 - Access denied for user 'root'@'localhost'" when testing the phpMyAdmin.

If I try and re-do the steps, I get the following error "ERROR 1044 (42000): Access denied for user ''@'localhost' to database mysql'" when I try to change the password.
A: This seems to be happening because of the combination of Windows 7 and a
new version of WampServer 2.1. Here's another approach that should work
for the new combination.

Follow these steps instead of the ones using the CMD prompt. (As a bonus, they're much easier!)
  1. Left-click on the WampServer icon tray.
  2. Choose phpMyAdmin.
  3. When the phpMyAdmin page opens in your browser, click the Privileges tab found after the Engines tab.
  4. Locate the line in the User table with "root - localhost - No..." (probably the last one).
  5. Click the Edit icon (the final item in the row).
  6. Scroll down to the Change Password section.
  7. Select Password and enter your password twice. (If you're following the exercises, enter root).
  8. Click Go in the lower-right corner.
Now follow the rest of the steps in "Setting up a MySQL password for Windows" video, starting at the 4:13 mark. This is where you use a text editor to make a change in the config.inc PHP file and restart all WampServer services when you're done.
Q:  I want to setup the practice files and site on my localhost, as described; however, I already have my current WordPress site (under development) running on my localhost. How do I run two WordPress sites on my localhost?
A:  You can easily do it by setting up another site in Dreamweaver. Just copy the WordPress files to that folder as described and establish a new database via phpMyAdmin. You can set up as many WordPress sites as you need to. The author has upwards of 80 on his system, all for different clients.
Q: This course was updated on 10/23/2012. What changed?
A: The course was thoroughly revised and uses the most current versions of both programs. We added chapters on responsive design and creating a custom administration panel in WordPress, new movies about concepts and taxonomies, and extended the Spry chapter to include jQuery, among other changes. New movies are indicated by the NEW tag next to the movie name.
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

* Estimated file size

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


You have completed Dreamweaver and WordPress: Core Concepts.

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

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 ?

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 preferences from 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.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

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.