• Item 1
  • Item 2
  • Item 3
  • My UNC Charlotte

  • Directory

  • Campus Events

  • Library

  • Prospective Students

    • About UNC Charlotte
    • Campus Life
    • Admissions
    • Graduate Admissions
  • Faculty and Staff

    • Human Resources
    • Auxiliary Services
    • Inside UNC Charlotte
    • Academic Affairs
  • Current Students

    • Athletics
    • Financial Aid
    • Advising
    • Student Health Center
  • Alumni and Friends

    • Alumni Association
    • Advancement
    • Foundation
    • Make a Gift
Aaron Forsyth
Aaron Forsyth
Academic Technologies Developer
  • My UNC Charlotte

  • Directory

  • Campus Events

  • Library

  • Prospective Students

    • About UNC Charlotte
    • Campus Life
    • Admissions
    • Graduate Admissions
  • Faculty and Staff

    • Human Resources
    • Auxiliary Services
    • Inside UNC Charlotte
    • Academic Affairs
  • Current Students

    • Athletics
    • Financial Aid
    • Advising
    • Student Health Center
  • Alumni and Friends

    • Alumni Association
    • Advancement
    • Foundation
    • Make a Gift
  • Updates
  • UNC Charlotte
  • WordPress
  • HighEd Web

Contact Me

Office: Barnard 232
Phone: x70166
Email: aaronforsyth@uncc.edu

Links

  • My Department – OAT

Tips and Tricks

March 09, 2018 by Aaron Forsyth
Categories: Updates

As I’ve been working to update our instances of WordPress to the new theme, I’ve learned a few things.  I thought I’d take a minute to document them for myself (and anyone else who cares to read).

Source Code for a Page

Viewing the source code for a page can be helpful when troubleshooting problems on a page.  Typically I use the Chrome inspector to see the underlying HTML/CSS and resolve an issue.  In this case, however, I was trying to compare a page in our production and development environments.  I pulled up the source for both pages and did a diff on them using Notepad++.  The files were identical.  But when I looked at the pages in the Chrome inspector, there were clear differences.  Ultimately, I discovered that viewing the source only shows what the server sent at the time the browser requested the particular webpage.  This does not include changes made on the client by JavaScript. 

WP URL Autocomplete

I also learned that WordPress will autocomplete URLs for you.  For example, this post is located at https://pages.charlotte.edu/forsyth/blog/2018/03/09/tips-and-tricks/, but if you only input https://pages.charlotte.edu/forsyth/blog/2018/03/09/tips into the address bar, WordPress will still navigate to this post.  In WordPress this is called canonical redirect.

WP Menus

WordPress allows users to automatically add new top-level pages to a WordPress menu.  You can select this option by checking the box below your menu.  

However, subpages – pages you create with a parent using the page hierarchy – don’t get added automatically.  I’m not sure why WordPress has not implemented this as it seems intuitive to me.  In fact, if you do not create a menu and your theme allows a fallback, then WordPress will create a menu including subpages, using a function called wp_list_pages.  Having a fallback menu complicates things in it’s own way.  For example, if you do not want a menu, you have to create a menu with no menu items.  Very counter-intuitive.  I’ve done a couple of things to try to “fix” this.  First, since our theme previously used a fallback, many sites were relying on that fallback.  I wrote a script to create menus for those sites, which mirrored the menu they had previously.  The new menu, called Page Hierarchy Menu, automatically adds new top-level pages.  Then I added a plugin called Auto Submenu to take care of any subpages.  

Click for more  

UNC Charlotte Homepage

Campus Links

  • Alerts
  • Jobs
  • Make a Gift
  • Maps / Directions
  • Accessibility

Resources

  • Alumni & Friends
  • Faculty & Staff
  • Prospective Students
  • Community
  • Current Students
  • Parents and Family

Stay In Touch

facebook instagram flickr linkedin twitter youtube maps

The University of North Carolina at Charlotte
9201 University City Blvd, Charlotte, NC 28223-0001
704-687-8622

© 2017 UNC Charlotte | All Rights Reserved
Contact Us | Terms of Use | University Policies
Skip to toolbar
  • Log In