Wouldn’t you know it.
As soon as I posted the previous post I got it to work!!!
Ok here is how I have it.
The plugin creates a menu page with a form to allow person info to be inserted into the database. It also creates a new page with the shortcode [pedigree id = “‘ . $id . ‘”] automatically inserted with the person id :
<?php
$strSql = 'select last_insert_id() as lastId';
$result = mysql_query($strSql);
while($row = @mysql_fetch_assoc($result)){
$id = $row['lastId'];
}
$new_post = array(
'post_title' => $id. " " . $first_name . " " . $family_name,
'post_content' => '[pedigree id = "' . $id . '"]',
'post_status' => 'publish',
'post_author' => $user_ID,
'post_type' => 'page',
'post_category' => array(0)
);
$post_id = wp_insert_post($new_post, $wp_error );
echo $post_id
?>
I have a shortcode.php file which I store the shortcodes functions. This file is included into install.php file which has the wordpress header comments for the plugin.
shortcode.php
<?php
function pedigree($atts) {
extract(shortcode_atts( array(
'id' => ' ',
), $atts ) );
return include ('addin-pedigree.php');
}
add_shortcode('pedigree', 'pedigree');
?>
I then use a file called addin-pedigree.php to hold the code:
addin-pedigree.php
<?php
global $wpdb;
$result = $wpdb->get_row ( 'SELECT * FROM wp_lb_person WHERE id = "'.$id.'"');
echo $result->first_name. " " . $result->family_name. "<br />";
echo $result->date_of_birth. "<br />";
echo $result->date_of_death. "<br />";
?>
This appears to run ok and it displays the correct information, but the number one appears below it.
John Barton
01/01/2001
01/01/2001
1 <- This is the problem
Live Page: https://lyons-barton.com/17-john-barton/
The shortcode that is used is [pedigree id = “17”] (Derived from [pedigree id = “‘ . $id . ‘”])
I hope this answers your question (and is not to confusing)
Thanks
Warwick