Forum Replies Created

Viewing 3 replies - 16 through 18 (of 18 total)
  • Thread Starter wdlyons

    (@wdlyons)

    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

    Thread Starter wdlyons

    (@wdlyons)

    Hi,

    I will forward the details on shortly.
    I have been playing around myself and have stuffed it up somehow. I can no longer get anything working. As soon as I do i will post the answers to your questions here.

    Again Thanks for your help

    Warwick

    Thread Starter wdlyons

    (@wdlyons)

    Hi Thanks for your reply

    function pedigree() {

    `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 />”;

    }

    add_shortcode(‘add-pedigree’, ‘pedigree’); `

    David Lyons
    02/02/2001
    02/02/2001
    1 <- This appears My Query is how do I stop it from appearing

    Thanks again for your reply

Viewing 3 replies - 16 through 18 (of 18 total)