Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've recently moved my fishkeeping "species profiles" over from a custom DB to a customised WordPress custom post type.

I did this by creating a PHP file which accessed the former database, extracted the appropriate information and inserted it into the WP database.

This has worked for all of the profiles and all attached media, but some of my references (key of the meta field) don't display in back nor front-end, despite being in the database.

Here's one of the references that has been pulled over which IS displaying:

Array
(
    [0] => Array
        (
            [ref_doc_title] => The fighting fishes (Teleostei: Osphronemidae: Genus Betta) of Singapore, Malaysia and Brunei.
            [ref_pub_year] => 
            [ref_page_nums] => Raffles Bull. Zool. Supplement (13):43-99. 2005
            [ref_publishers] => 
            [ref_authors] => Tan, H.H. and P.K.L. Ng.
        )

    [1] => Array
        (
            [ref_doc_title] => The fishes of Danau Sentarum National Park and the Kapuas Lakes area, Kalimantan Barat, Indonesia.
            [ref_pub_year] => 
            [ref_page_nums] => Raffles Bull. Zool. Supplement (13):139-173. 2005
            [ref_publishers] => 
            [ref_authors] => Kottelat, M. and E. Widjanarti.
        )

    [2] => Array
        (
            [ref_doc_title] => 
            [ref_pub_year] => 
            [ref_page_nums] => www.fishbase.org
            [ref_publishers] => 
            [ref_authors] => 
        )

    [3] => Array
        (
            [ref_doc_title] => 
            [ref_pub_year] => 
            [ref_page_nums] => www.ibcbettas.org
            [ref_publishers] => 
            [ref_authors] => 
        )

    [4] => Array
        (
            [ref_doc_title] => 
            [ref_pub_year] => 
            [ref_page_nums] => www.petfrd.com
            [ref_publishers] => 
            [ref_authors] => 
        )

)

And it looks like this in the database:

a:5:{i:0;a:5:{s:13:"ref_doc_title";s:94:"The fighting fishes (Teleostei: Osphronemidae: Genus Betta) of Singapore, Malaysia and Brunei.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:47:"Raffles Bull. Zool. Supplement (13):43-99. 2005";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:24:"Tan, H.H. and P.K.L. Ng.";}i:1;a:5:{s:13:"ref_doc_title";s:98:"The fishes of Danau Sentarum National Park and the Kapuas Lakes area, Kalimantan Barat, Indonesia.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:49:"Raffles Bull. Zool. Supplement (13):139-173. 2005";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:31:"Kottelat, M. and E. Widjanarti.";}i:2;a:5:{s:13:"ref_doc_title";s:0:"";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:16:"www.fishbase.org";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:0:"";}i:3;a:5:{s:13:"ref_doc_title";s:0:"";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:17:"www.ibcbettas.org";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:0:"";}i:4;a:5:{s:13:"ref_doc_title";s:0:"";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:14:"www.petfrd.com";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:0:"";}}

Then I have one which isn't working:

Array
(
    [0] => Array
        (
            [ref_doc_title] => Revision of the family Badidae (Teleostei: Perciformes), with description of a new genus and ten new species. 
            [ref_pub_year] => 
            [ref_page_nums] => Ichthyol. Explor. Freshwat. 13(4): 295-372. 
            [ref_publishers] => 
            [ref_authors] => Kullander, S.O. and R. Britz. 2002
        )

    [1] => Array
        (
            [ref_doc_title] => Evolutionary and biogeographic patterns of the Badidae (Teleostei: Perciformes) inferred from mitochondrial and nuclear DNA sequence data.
            [ref_pub_year] => 
            [ref_page_nums] => Mol. Phylogen. and Evol. 32(3): 1010-1022.
            [ref_publishers] => 
            [ref_authors] => Rüber, L., R. Britz, S. O. Kullander and R. Zardoya. 2004
        )

)

And this is how it looks in the database:

a:2:{i:0;a:5:{s:13:"ref_doc_title";s:110:"Revision of the family Badidae (Teleostei: Perciformes), with description of a new genus and ten new species. ";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:44:"Ichthyol. Explor. Freshwat. 13(4): 295-372. ";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:34:"Kullander, S.O. and R. Britz. 2002";}i:1;a:5:{s:13:"ref_doc_title";s:138:"Evolutionary and biogeographic patterns of the Badidae (Teleostei: Perciformes) inferred from mitochondrial and nuclear DNA sequence data.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:42:"Mol. Phylogen. and Evol. 32(3): 1010-1022.";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:57:"Rüber, L., R. Britz, S. O. Kullander and R. Zardoya. 2004";}}

The code that I'm using in the back-end is as follows:

function meta_references() {
    global $post;

    if ($post) {
        $references = get_post_meta( $post->ID , 'references', TRUE );
        if (get_post_meta( $post->ID, 'ref_type_desc', TRUE) != "") {
            $ref_type_desc = get_post_meta( $post->ID, 'ref_type_desc', TRUE);
        } else {
            $ref_type_desc = -1;
        }
    }
    ?>
<div class="meta_control normal">
    <div id="references_wrapper">
        <p>Click <a href="javascript:void(0);" id="add_reference">here</a> to add a new reference.</p>
    <?php
        if (!empty($references)) {
            $count = count($references);
            for ($i = 1; $i <= $count; $i++) {
                if ($ref_type_desc != -1 && $i == $ref_type_desc) {
                    $this->print_reference($i, $references[$i-1], TRUE);
                } else {
                    $this->print_reference($i, $references[$i-1]);
                }
            }
        } else {
            $this->print_reference(1);
        }
    ?>
        <p>Click <a href="javascript:void(0);" id="uncheck_ref_radio">here</a> to unset the Type Description buttons.</p>
    </div>
</div>
    <?php
}

function print_reference($i, $array = NULL, $type_desc = NULL) {
    // any information below must be changed in references.js
    ?>
<div class="reference">
    <h3>Reference <?php echo $i; ?></h3>
    <div class="line double">
        <label>Author(s)</label> <input type="text" name="ref_authors[]" value="<?php if (isset($array["ref_authors"])) { echo $array["ref_authors"]; } ?>" />
        <label>Publisher</label> <input type="text" name="ref_publishers[]" value="<?php if (isset($array["ref_publishers"])) { echo $array["ref_publishers"]; } ?>" />
    </div>
    <div class="line double">
        <label>Publication Year</label> <input type="text" name="ref_pub_year[]" value="<?php if (isset($array["ref_pub_year"])) { echo $array["ref_pub_year"]; } ?>" />
        <label>Page Number(s)</label> <input type="text" name="ref_page_nums[]"  value="<?php if (isset($array["ref_page_nums"])) { echo $array["ref_page_nums"]; } ?>" />
    </div>
    <div class="line"><label>Document Title</label> <input type="text" name="ref_doc_title[]" value="<?php if (isset($array["ref_doc_title"])) { echo $array["ref_doc_title"]; } ?>" /></div>
    <div class="line"><label style="width:150px;">Type Description?</label> <input type="radio" class="ref_type_desc" name="ref_type_desc" style="padding-top:5px;margin-top:5px;" value="<?php echo $i; ?>"<?php if ($type_desc == TRUE) { echo 'checked = "checked"'; } ?> /></div>
    <div style="clear:both;line-height:0;margin:0;padding:0;">&nbsp;</div>
    <p>Click <a href="javascript:void(0);" id="<?php echo $i; ?>_del_reference">here</a> to remove Reference #<?php echo $i; ?>.</p>
</div>
    <?php
}

And the code that I'm using on the front-end is:

if (get_post_meta($post->ID, 'references', TRUE) != "") {
    $references = get_post_meta($post->ID, 'references', TRUE);
    if (strlen($references[0]["ref_doc_title"]) > 0) {
        echo '<h2 id="references" class="profile_literaturecited">References</h2>' . "\n";

        echo '<ol>';

        if (get_post_meta($post->ID, 'ref_type_desc', TRUE) != "") {
            $type_desc = get_post_meta($post->ID, 'ref_type_desc', TRUE);

            $count = count($references);

            for ($i = 1; $i <= $count; $i++) {
                if ($i == $type_desc) {
                    $n = $i - 1;
                    $r = $references[$n];
                    echo '<li class="type_desc">';
                    echo '<strong>' . $r["ref_authors"] . ', ' . $r["ref_pub_year"] . '</strong>';
                    echo ' - ' . $r["ref_publishers"] . ': ' . $r["ref_page_nums"];
                    echo '<br />' . $r["ref_doc_title"];
                    echo '</li>';

                    unset($references[$n]);
                }
            }
        }
        // user defined sort comparison. use lowercase to ensure sort is accurate
        function cmp($a, $b)
        {
            $al = strtolower($a["ref_authors"]);
            $bl = strtolower($b["ref_authors"]);
            if ($al == $bl) {
                return 0;
            }
            return ($al > $bl) ? +1 : -1;
        }

        usort($references, "cmp");

        foreach ($references as $r) {
            echo '<li>';
            echo '<strong>' . $r["ref_authors"] . ', ' . $r["ref_pub_year"] . '</strong>';
            echo ' - ' . $r["ref_publishers"] . ': ' . $r["ref_page_nums"];
            echo '<br />' . $r["ref_doc_title"];
            echo '</li>';
        }
        echo '</ol>';
    }
}

Nothing at all displays in the back-end or front-end for any of these "non-working" references, yet the entries are in the database with the correct post ID and meta_key.

So I'm wondering, is this serialized array (the non-working one) somehow malformed for WordPress usage? I don't think it's malformed by PHP standards as I can print_r it perfectly using the unserialize command.

Any help would be much appreciated, I think I'm going crazy!

EDIT for Chip

Here is the (abridged) output of your code for one of the species profiles which DOESN'T display the references. I've removed the lengthy snippets of other meta fields, but left two other meta printouts in to show how they return.

array(19) {
  ["genus"]=>
  array(1) {
    [0]=>
    string(20) "Yasuhikotakia"
  }
  ["species"]=>
  array(1) {
    [0]=>
    string(16) "splendida"
  }

....

 ["references"]=>
  array(1) {
    [0]=>
    string(4117) "a:12:{i:0;a:5:{s:13:"ref_doc_title";s:74:"Genetic variation of five species of Yasuhikotakia in Thailand using AFLP.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:48:"Journal of Agricultural Technology 6(4): 761-766";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:60:"Arthainsee, A., T. Leamkom, A. Jutagate and S. Chundum. 2010";}i:1;a:5:{s:13:"ref_doc_title";s:48:"The Botia modesta complex (Cobitidae, Botiinae).";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:22:"Ichthyofile No. 1: 1-8";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:14:"Grant, S. 2001";}i:2;a:5:{s:13:"ref_doc_title";s:15:"Fishes of Laos.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:52:"WHT Publications Ltd., Colombo 5, Sri Lanka. 198 p. ";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:17:"Kottelat, M. 2001";}i:3;a:5:{s:13:"ref_doc_title";s:168:"Botia kubotai, a new species of loach (Teleostei: Cobitidae) from the ataran River basin (Myanmar), with comments on botiinae nomenclature and diagnosis of a new genus.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:17:"Zootaxa 401: 1-18";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:17:"Kottelat, M. 2004";}i:4;a:5:{s:13:"ref_doc_title";s:96:"Sixty million years of evolution. Part one: family Botiidae (Pisces: Ostariophysi: Cobitoidea). ";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:81:"Travaux du Museum d'Histoire Naturelle "Grigore Antipa" 44: 309-333";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:19:"Nalbant, T. T. 2002";}i:5;a:5:{s:13:"ref_doc_title";s:128:"Hymenphysa, Hymenophysa, Syncrossus, Chromobotia and other problems in the systematics of Botiidae. A reply to Maurice Kottelat.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:82:"Travaux du Museum d'Histoire Naturelle "Grigore Antipa" 47: 269-277.";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:19:"Nalbant, T. T. 2004";}i:6;a:5:{s:13:"ref_doc_title";s:90:"Botia splendida, a new species of loach (Pisces: Cobitidae) from the Mekong Basin in Laos.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:46:"The Raffles Bulletin of Zoology 43(2): 463-467";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:19:"Roberts, T. R. 1995";}i:7;a:5:{s:13:"ref_doc_title";s:147:"Molecular phylogeny of the Southeast Asian freshwater fish family Botiidae (Teleostei: Cobitoidea) and the origin of polyploidy in their evolution.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:49:"Molecular Phylogenetics and Evolution 39: 529-541";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:53:"Šlechtová, V., J. Bohlen, J. Freyhof and P. Ráb. 2006";}i:8;a:5:{s:13:"ref_doc_title";s:188:"Families of Cobitoidea (Teleostei; Cypriniformes) as revealed from nuclear genetic data and the position of the mysterious genera Barbucca, Psilorhynchus, Serpenticobitis and Vaillantella.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:54:"Molecular Phylogenetics and Evolution 44(3): 1358-1365";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:44:"Šlechtová, V., J. Bohlen and H. H. Tan. 2007";}i:9;a:5:{s:13:"ref_doc_title";s:72:"Two new species of the cobitid genus [ì]Botia from the Lao Mekong Basin.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:46:"Japanese Journal of Ichthyology 42(2): 147-155";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:25:"Taki, Y. and A. Doi. 1995";}i:10;a:5:{s:13:"ref_doc_title";s:126:"Phylogeny of the East Asian botiine loaches (Cypriniformes, Botiidae) inferred from mitochondrial cytochrome b gene sequences.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:29:"Hydrobiologia 544(1): 249-258";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:44:"Tang, Q., B. Xiong, X. Yang and H. Liu. 2005";}i:11;a:5:{s:13:"ref_doc_title";s:177:"Comparison of evolutionary rates in the mitochondrial DNA cytochrome b gene and control region and their implications for phylogeny of the Cobitoidea (Teleostei: Cypriniformes).";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:52:"Molecular Phylogenetics and Evolution 39(2): 347-357";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:46:"Tang, Q., H. Liu, R. Mayden and B. Xiong. 2006";}}"
  }
  ["_thumbnail_id"]=>
  array(1) {
    [0]=>
    string(5) "25351"
  }
  ["attached_media"]=>
  array(1) {
    [0]=>
    string(156) "a:12:{i:0;i:25351;i:1;i:25352;i:2;i:25353;i:3;i:25354;i:4;i:25355;i:5;i:25356;i:6;i:25357;i:7;i:25358;i:8;i:25359;i:9;i:253510;i:10;i:253511;i:11;i:253512;}"
  }

On one of the profiles that works, it displays in a similar manner:

["references"]=>
  array(1) {
    [0]=>
    string(1145) "a:5:{i:0;a:5:{s:13:"ref_doc_title";s:94:"The fighting fishes (Teleostei: Osphronemidae: Genus Betta) of Singapore, Malaysia and Brunei.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:47:"Raffles Bull. Zool. Supplement (13):43-99. 2005";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:24:"Tan, H.H. and P.K.L. Ng.";}i:1;a:5:{s:13:"ref_doc_title";s:98:"The fishes of Danau Sentarum National Park and the Kapuas Lakes area, Kalimantan Barat, Indonesia.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:49:"Raffles Bull. Zool. Supplement (13):139-173. 2005";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:31:"Kottelat, M. and E. Widjanarti.";}i:2;a:5:{s:13:"ref_doc_title";s:0:"";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:16:"www.fishbase.org";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:0:"";}i:3;a:5:{s:13:"ref_doc_title";s:0:"";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:17:"www.ibcbettas.org";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:0:"";}i:4;a:5:{s:13:"ref_doc_title";s:0:"";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:14:"www.petfrd.com";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:0:"";}}"
  }

** FINAL EDIT **

@goldenapples was correct with his answer.

I've now opened a new question on Stackoverflow (as it isn't WordPress specific).

http://stackoverflow.com/questions/9088910/migrating-data-from-latin1-charset-to-utf-8

If any of you can help it would be much appreciated!

share|improve this question
    
What is your database collation set to for the postmeta table? I may be going out on a limb, but I'm wondering if the umlaut in the non-working references entry for one of the author's names could be causing a problem reading that entry. Can you check that your database table collation is set to the same value as the blog_charset option in WordPress? –  goldenapples Jan 31 '12 at 19:11
    
Specifically, different character encodings can change the character count of a field, which can cause it to be unreadable. ü in UTF-8 is stored as two characters 195 188, while in ISO its the single character code 252. –  goldenapples Jan 31 '12 at 19:15
    
Hmm that's an interesting concept and might well be applicable. The collation on postmeta and the new DB is utf8_general_ci but the old DB was latin1_swedish_ci. Any suggestions for a fix? –  dunc Jan 31 '12 at 19:42
    
Check my answer below about using htmlentities() to sanitize strings before serializing them and saving them into postmeta. Depending on what the values are that you're saving, you may want to use sanitize_text_field() instead, which also strips tags and converts a lot more entities... –  goldenapples Jan 31 '12 at 19:58
add comment

2 Answers

up vote 1 down vote accepted

See my comment on your question above. I just realized that if you're ending up with those special characters in the database, most likely you're not sanitizing the data before saving it into the database. Try running htmlentities() over all the values that you're saving into that serialized array, and see if you end up with a readable result.

share|improve this answer
    
OK, will do in an hour or so. I'll let you know how I get on. –  dunc Jan 31 '12 at 20:18
    
Hi goldenapples. Looks like you were right! I can now import the references by escaping the data with htmlentities. However, most of the non-standard characters have now disappeared entirely. I.e. where I had Slavak (with a non-standard S that I can't replicate), the entire "ref_authors" field from the serialized array has disappeared. Any ideas? –  dunc Jan 31 '12 at 22:25
    
Going to give you the credit golden, but I'm opening a new question on Stackoverflow as I'm still somewhat stuck! URL in my original question if you can help. –  dunc Feb 1 '12 at 0:03
    
Thanks. Yes, charset conversion has bitten me a few times. I looked at your question and at what you've done, but I'm not sure I can help any more. The answer I'm pretty sure is in some application of PHP's iconv function, combined with an aggressive version of htmlentities/htmlspecialchars, but I can't tell you just how to do it. –  goldenapples Feb 1 '12 at 0:54
add comment

Have you read the Codex entry for get_post_meta()?

It notes that meta values that are serialized arrays are a bit of a special case, primarily impacting the $single parameter in the get_post_meta($post_id, $key, $single) call:

$single

(boolean) (optional) If set to true then the function will return a single result, as a string. If false, or not set, then the function returns an array of the custom fields. This is not intuitive. For example, if you fetch a serialized array with this method you want $single to be true to actually get an unserialized array back. If you pass in false, or leave it out, you will have an array of one, and the value at index 0 will be the serialized string.

Default: false

You do appear to be handling this properly, though.

To see if WordPress can read the array properly, try this:

<?php
$post_references = ( get_post_meta( $post->ID , 'references', TRUE ) ? get_post_meta( $post->ID , 'references', TRUE ) : false );
var_dump( $post_references );
?>

I suspect that this will return your array; in which case, you simply need to step into it:

<?php
foreach ( $post_references as $post_reference ) {
    // Get the ref doc title
    $ref_doc_title = $post_reference['ref_doc_title'];
    // Do whatever you need/want here;
    // Output a list, or whatever
}
?>

But if it doesn't return your array, we'll need to figure out where else the problem might be.

Edit

It returns bool(false) on the profiles where the references aren't appearing in the front-end or the back-end (as per example 2)...

That means that get_post_meta() itself isn't returning anything for the references meta field for the post in question. Let's find out what WordPress does find as custom meta data for this post:

<?php
$all_post_custom_data = get_post_custom( $post->ID );
var_dump( $all_post_custom_data );
?>

Does references show up in this var_dump? If so, what does it look like?

Edit 2

Based on your var_dump results:

["references"]=>
  array(1) {
    [0]=>
    string(4117) "a:12:{i:0;a:5:{s:13:"ref_doc_title";s:74:"Genetic variation of five species of Yasuhikotakia in Thailand using AFLP.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:48:"Journal of Agricultural Technology 6(4): 761-766";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:60:"Arthainsee, A., T. Leamkom, A. Jutagate and S. Chundum. 2010";}i:1;a:5:{s:13:"ref_doc_title";s:48:"The Botia modesta complex (Cobitidae, Botiinae).";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:22:"Ichthyofile No. 1: 1-8";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:14:"Grant, S. 2001";}i:2;a:5:{s:13:"ref_doc_title";s:15:"Fishes of Laos.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:52:"WHT Publications Ltd., Colombo 5, Sri Lanka. 198 p. ";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:17:"Kottelat, M. 2001";}i:3;a:5:{s:13:"ref_doc_title";s:168:"Botia kubotai, a new species of loach (Teleostei: Cobitidae) from the ataran River basin (Myanmar), with comments on botiinae nomenclature and diagnosis of a new genus.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:17:"Zootaxa 401: 1-18";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:17:"Kottelat, M. 2004";}i:4;a:5:{s:13:"ref_doc_title";s:96:"Sixty million years of evolution. Part one: family Botiidae (Pisces: Ostariophysi: Cobitoidea). ";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:81:"Travaux du Museum d'Histoire Naturelle "Grigore Antipa" 44: 309-333";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:19:"Nalbant, T. T. 2002";}i:5;a:5:{s:13:"ref_doc_title";s:128:"Hymenphysa, Hymenophysa, Syncrossus, Chromobotia and other problems in the systematics of Botiidae. A reply to Maurice Kottelat.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:82:"Travaux du Museum d'Histoire Naturelle "Grigore Antipa" 47: 269-277.";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:19:"Nalbant, T. T. 2004";}i:6;a:5:{s:13:"ref_doc_title";s:90:"Botia splendida, a new species of loach (Pisces: Cobitidae) from the Mekong Basin in Laos.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:46:"The Raffles Bulletin of Zoology 43(2): 463-467";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:19:"Roberts, T. R. 1995";}i:7;a:5:{s:13:"ref_doc_title";s:147:"Molecular phylogeny of the Southeast Asian freshwater fish family Botiidae (Teleostei: Cobitoidea) and the origin of polyploidy in their evolution.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:49:"Molecular Phylogenetics and Evolution 39: 529-541";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:53:"Šlechtová, V., J. Bohlen, J. Freyhof and P. Ráb. 2006";}i:8;a:5:{s:13:"ref_doc_title";s:188:"Families of Cobitoidea (Teleostei; Cypriniformes) as revealed from nuclear genetic data and the position of the mysterious genera Barbucca, Psilorhynchus, Serpenticobitis and Vaillantella.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:54:"Molecular Phylogenetics and Evolution 44(3): 1358-1365";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:44:"Šlechtová, V., J. Bohlen and H. H. Tan. 2007";}i:9;a:5:{s:13:"ref_doc_title";s:72:"Two new species of the cobitid genus [ì]Botia from the Lao Mekong Basin.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:46:"Japanese Journal of Ichthyology 42(2): 147-155";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:25:"Taki, Y. and A. Doi. 1995";}i:10;a:5:{s:13:"ref_doc_title";s:126:"Phylogeny of the East Asian botiine loaches (Cypriniformes, Botiidae) inferred from mitochondrial cytochrome b gene sequences.";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:29:"Hydrobiologia 544(1): 249-258";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:44:"Tang, Q., B. Xiong, X. Yang and H. Liu. 2005";}i:11;a:5:{s:13:"ref_doc_title";s:177:"Comparison of evolutionary rates in the mitochondrial DNA cytochrome b gene and control region and their implications for phylogeny of the Cobitoidea (Teleostei: Cypriniformes).";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:52:"Molecular Phylogenetics and Evolution 39(2): 347-357";s:14:"ref_publishers";s:0:"";s:11:"ref_authors";s:46:"Tang, Q., H. Liu, R. Mayden and B. Xiong. 2006";}}"
  }

We can tell that references is getting stored as a serial array string. That may or may not be as intended; do you get the same thing from the posts with working references meta data?

It looks like you're going to need to do one of two things:

  1. Re-import your data, unserialized, so that it is accessible as per normal
  2. Unserialize your data when you output it.

I don't know if the latter will actually work, since get_post_meta() didn't even return anything for references.

Ultimately, I think the answer is that your import script imported some data serialized, and some data unserialized. The solution will probably be to re-import your data, so that all data are imported consistently.

share|improve this answer
    
Thanks Chip, I'll give this a go shortly and let you know. –  dunc Jan 31 '12 at 15:37
    
Hi again Chip. It returns bool(false) on the profiles where the references aren't appearing in the front-end or the back-end (as per example 2), but displays the var_dump of the array for species where they do appear to be working (as per example 1). –  dunc Jan 31 '12 at 15:58
1  
Okay, that means that WordPress isn't finding references as post meta for this post. See updated answer. –  Chip Bennett Jan 31 '12 at 16:34
    
Hi Chip, I've updated my original post with the required information. –  dunc Jan 31 '12 at 18:17
1  
Yeah, I would agree: if in all cases the serialized arrays are valid, then the issue must the the serialized data. So: back to how the data were imported into the DB in the first place. –  Chip Bennett Jan 31 '12 at 20:52
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.