Return to Snippet

Revision: 39731
at January 20, 2011 06:11 by ashworthconsulting


Updated Code
<?php

// Include Wordpress framework/API
require_once( '/path/to/wp-load.php' );


// Get parents (level one)
$items_level_one = $wpdb->get_results(
	'SELECT
		*
	FROM
		wp_posts
	WHERE
		post_type = "Page" AND
		post_status = "Publish" AND
		post_parent = "[put parent id here]"
	ORDER BY
		menu_order,
		post_title',
	ARRAY_A
);

print_r($items_level_one);

?>

Revision: 39730
at January 20, 2011 06:11 by ashworthconsulting


Initial Code
<?php

// Include Wordpress framework/API
require_once( '/path/to/wp-load.php' );


// Get parents (level one)
$items_level_one = $wpdb->get_results(
	'SELECT
		*
	FROM
		wp_posts
	WHERE
		post_type = "Page" AND
		post_status = "Publish" AND
		post_parent = "[put parent id here]"
	ORDER BY
		menu_order,
		post_title',
	ARRAY_A
);

print_r($items_level_one);

?>

Initial URL

                                

Initial Description
Plugin gets child pages of parent in Wordpress. You'll need to pass the parent ID but this isn't difficult to figure out programmatically if needed, either.

Initial Title
Get children of parent with MySQL SELECT query

Initial Tags
mysql, wordpress

Initial Language
PHP