19 | Troubleshooting wordpress themes


here is a little trick if you need to check some variables, or try something new in your wordpress theme while the site is live.
use a conditional if statement to check that you are logged in as the original administrator, and only then do what you need to do. this way you can perform and display the neccesary tests, without the public seing anything.

if ('1' == $user_ID) :
echo 'you are logged in - this will not be shown to the public: <br/><br/>';
  // test routine begin //
echo 'cat-id , cat-slug , cat-name , number of posts <br/><br/>';
$categories= get_categories('');
foreach ($categories as $cat) {
echo $cat->cat_ID.' , '.$cat->category_nicename.' , '.$cat->cat_name.' , '.$cat->category_count.'<br/>';
  // test routine ends //
echo '<br/>end of logged in section <br/>';
endif; ?>

in this example, i displayed a full list of all categories with id, slug, and name.

the wordpress back-end (dashboard) is generally a good place to work, however for developers, some lists don’t show all the variables or parameters that would be useful for programming custom displays or functions. for instance, the IDs of posts, pages, categories, tags, etc. are not easily found in the back-end.

you can (and sometimes need to) build your own code snippets to show them on the spot where you are working with them.
this avoids a lot of guesswork.

and now you know how to hide these displays from public view.

This entry was posted in WordPress and tagged , , . Bookmark the permalink.

3 Responses to Troubleshooting wordpress themes

  1. Kent comments:

    Not sure if you can offer a suggestion, but it’s worth asking, right?

    I have been using the “Envisioned” WP picture theme for the past month and it has been working fine (slightly slow though). All of a sudden, yesterday, the server cannot handle it (godaddy), I get a this error: [i]The server is temporarily unable to service your request due to maintenance downtime or capacity problems[/i]

    I was able to change my theme back to twenty11 and the site runs super fast on that so I narrowed it down to an Envision theme problem. I had made some modifications to some of the theme files so I decided to download envisioned again and replace every single php file with fresh ones but I am still having problems. I did not replace the css files or images because those are not script related. (maybe this newer version of envision from april 2012 is not good and I need to replace some other files to make it work?)

    I also disabled all plugins to see with that would help but no.

    Another big clue is that I can log into godaddy and see the system processes that are running. With the twenty11 theme, there are only 3 running. With Envisioned, there are 25 to 70! Any reason why this is so high?

    Also, to make things more weird, I was not editing any theme or core files when everything hit the fan. I was only editing a post and I had recently activated “load first image” for thumbnail or what ever that was called in the ePanel.

    Any help or answers would greatly be appreciated. I’ve spent over 50 hours modifying the look of this template and I am at a complete loss as of what to do other than start all over modifying a less heavy theme.

  2. wparena comments:

    This article is ideal for any WordPress site owner who is currently having site issues… have mentioned it in my post

Leave a Reply to alchymyth Cancel reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


This site uses Akismet to reduce spam. Learn how your comment data is processed.