I try to add information from a custom field into the metadata in the source code. While searching for the solutions I found some. As I am not really an expert I ask you guys. I want to add information for a Digital Object Identifier (DOI) from a custom field to the source code so that the Search Engine of Altmetrics can find it. Necessary meta tags are:

  • Identifier (e.g. citation_doi)
  • Title (e.g. citation_title)
  • Author (e.g. citation_author)
  • ISSN - if applicable (e.g. citation_issn)

Finally, it should look like this in the Page Source:

<meta name="citation_title" content="A qualitative study" />
<meta name="citation_journal_title" content="Accountability in Research" />
<meta name="citation_author" content="David Shaw" />
<meta name="citation_doi" scheme="doi" content="10.1080/08989621.2017.1413940" />
<meta name="citation_source" content="https://doi.org/10.1080/08989621.2017.1413940" />

Some more comments: the DOI is unique for every blogpost. If you want to see the page look here: https://elephantinthelab.org/ I could really need help, especially in which .php-File I should put the information. I am also happy if you know a plugin which does the job. All SEO plugins I tried are not flexible enough. Thank you, much appreciated!


You will first need to add some metaboxes to your posts. This has been answered a lot, and there are many posts on the internet about is, such as this full guide.

After adding metaboxes, you can hook into the wp_head action hook and output your metadata. Here's a simple piece of code that goes into your theme's functions.php file:

add_action ( 'wp_head', 'add_my_metadata' );
function add_my_metadata() {
    if ( is_single() ) {
        ?><meta name="citation_title" content="<?php echo get_post_meta( get_the_ID(), 'meta_key_here', true ); ?>" /><?php

Make sure that your theme has the wp_head() function inside its header.php file, so the action hook can actually print the above code.

  • I managed to build a meta box with "Meta Box"-Plugin where I can put something in the box. Also your function works as I see it in the source code. Unfortunately, the content is empty. I just replaced your 'meta_key_here' with what I think is the meta key. Do I need to change something else? And by the way: thank your so much for helping me! That's not my "home" coding language :) – Martin Schmidt Mar 2 '18 at 17:49
  • I managed now to have my own meta box and everything works perfectly fine except that the "content" says "Array" although there is a value in there. Do you have any idea? – Martin Schmidt Mar 2 '18 at 19:39
  • You have to set the last parameter of get_post_meta to true, so it returns a single value. Otherwise, it will return an array of metas. – Jack Johansson Mar 2 '18 at 21:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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