i've been playing around with WP and am getting the hang of the structure but have a quick question regarding development...
when you make something like this, for example i might replace a static website with a wordpress powered version, once its developed in say a sub folder out of public view, how do you then go about moving it to the root to become the live site without messing up loads of links etc?
I'm probably not doing it the best way possible, but I tend to develop the theme on a blog I run that I know's working (so I can see what it looks like with content in it (using the 'theme testdrive' plugin so that only I can see the theme in development)) and then when I'm ready to move it over I quickly scan through all the theme files looking for any link that's not relative and then swap it out. Yes it creates a situation where the site is originally up without content, but it doesn't take long at all to put the content in (if you've got it ready saved so you can just cut and paste it in to your new pages). At worst it'll take a few hours to transfer all the new content that way, but I know I wont have missed changing a link and I always install analytics on the old site for a load of reasons anyway so I know what time to do it, what time the site's quiet. Of course once it's up and running changing between themes and testing themes is much easier - just a click of a button - this is purely for when I'm converting a static site to a wordpress site.
and fini, i would like more informaiton on the idea of custom meta tags to vary which bits of information you are drawing... do you have a link or anything?
No problem. First off an apology if you spent any time googling it - I think wordpress calls them meta keys rather than tags - woops! Anyway, say, for example, you want to list all the posts/pages in a particular category - well you'd start with something like this:
Code:
<?php if (have_posts()) : ?>
<?php $variablename = new WP_Query("cat=XXXXXX"); while($variablename->have_posts()) :$variablename->the_post();?>
<li><a href="<?php the_permalink() ?>" ><?php the_title(); ?></a></li>
<?php endwhile; ?>
<?php else : ?>
<h2 align="center">Something went wrong</h2>
<p align="center">I'm sorry, but I'm incapable of writing proper php</p>
<?php endif; ?>
That's all very nice, but a bit boring. Say you want to add a photo next to each post name - this is where the meta key comes in. In each post/page what you want to do is set a custom field of, for example 'photo' with a link to wherever the photo's stored (users can still upload just by clicking on the picture button as it tells them the link). The code would now look like this
Code:
<?php if (have_posts()) : ?>
<?php $variablename = new WP_Query("cat=XXXXXX"); while($variablename->have_posts()) :$variablename->the_post();?>
<li><href="<?php the_permalink() ?>><img src="<?php echo get_post_meta($post->ID, "photo", true); ?>" alt="<?php the_title(); ?> /></a>
<a href="<?php the_permalink() ?>" ><?php the_title(); ?></a></li>
<?php endwhile; ?>
<?php else : ?>
<h2 align="center">Something went wrong</h2>
<p align="center">I'm sorry, but I'm just a bit rubbish at all this</p>
<?php endif; ?>
So what we've done there is used
get_post_meta to pull the link we saved in the custom field of the post - and now it displays the photo next to the post name.
An example where I've used this in the past would be for an 'employees' page. This way all the user has to do when adding a new employee is create the page for them, including the photo and putting it in the 'employees' category and the parent employees page will be able to see that employee without being changed at all. The page then displayed for each employee a nice big photo of them with their name underneath it (pulled from the title of the page) and their position (another meta key).
You can make this more complicated by querying it so that you only show posts with a certain custom fields or with certain values or whatever. For example you might only want to show a list of posts where the meta key 'featured' is present and has a value of 'yes' (some people do this by having a featured category, but I think that the meta key way is far better for SEO). Really when used with multiple loops this allows you to do whatever you want in a form that's really easy for users to create content for.
A good example of where meta-keys are used to good effect (sorry not going to link to any of my own examples
) is the
revolution pro-media theme where they've created a page that would be impossible to do in wordpress without the use of meta-keys.