WordPress : The easy Way To Add Extra Meta Data To Your Page

As part of my recent mini project, I needed to add certain meta data to different posts and pages; for example a thumbnail image for a gallery, image captions etc… In order to do this I used a great free plug-in called ‘Custom Fields‘.  After you install the plug-in you can create custom meta data that you can add to a page.  The clever bit about the plug-in is you can use condition logic to decide where your custom fields get applied, for example, for each different category you have you can automatically have different meta-data.  If you want to know more about the plug-in go through the plug-ins documentation as it is quite extensive.

In your code you can then iterate through your posts/pages and get the meta-data from the page, using the following snippet :

get_field('pdf_url', $pageChild->ID);

Using this plug-in I was very easily and quickly able to create a custom products gallery that linked to a details page. Full code example below :

$child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = ".$post->ID."    AND post_type = 'page' ORDER BY menu_order", 'OBJECT');    ?>
 ID);
$link = !empty($pdf) ? $pdf : get_permalink($pageChild->ID);
?>

Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge

More Posts