Title: Please explain DOI hyperlinking
Last modified: February 11, 2025

---

# Please explain DOI hyperlinking

 *  [Jim](https://wordpress.org/support/users/jwmc/)
 * (@jwmc)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/please-explain-doi-hyperlinking/)
 * I don’t understand how DOI hyperlinking is supposed to work. I have a custom 
   csl style that simply inserts the DOI variable between < and > (as ampersand 
   codes). When I copy the item out of Zotero (desktop app) as a bibliography and
   paste it into a document, the actual DOI is hyperlinked and it works:
 * Crous PW, Summerell BA, Carnegie AJ, Wingfield MJ, Hunter GC, Burgess TI, Andjic
   V, Barber PA, Groenewald JZ. 2009. Unravelling <I>Mycosphaerella</I>: do you 
   believe in genera? Pers – Int Mycol J 23(1):99–118 <[10.3767/003158509X479487](https://doi.org/10.3767/003158509X479487)
   >.
 * In Zotpress, the same style results in printing the same, correct text, but with
   no hyperlink:
 * Crous PW, Summerell BA, Carnegie AJ, Wingfield MJ, Hunter GC, Burgess TI, Andjic
   V, Barber PA, Groenewald JZ. 2009. Unravelling <I>Mycosphaerella</I>: do you 
   believe in genera? Pers – Int Mycol J 23(1):99–118 <10.3767/003158509X479487>.
 * What am I missing?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [Jim](https://wordpress.org/support/users/jwmc/)
 * (@jwmc)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/please-explain-doi-hyperlinking/#post-18300198)
 * Update: as a test, I updated the style without the < and > around the DOI variable.
   Getting Zotpress to see the update was quite a struggle. Part of it involved 
   emptying the account cache on Zotpress > Accounts. Anyway, it made no difference.
 *  Thread Starter [Jim](https://wordpress.org/support/users/jwmc/)
 * (@jwmc)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/please-explain-doi-hyperlinking/#post-18309152)
 * Katie, I’ve gotten to the bottom of this, and I would like to suggest a change
   to `shortcode.request.php`, the section `// Hyperlink DOIs`, beginning line 664.
   The change is shorter than the original, covers more cases, and causes ZP to 
   behave more like Zotero. When the style presents a DOI variable, there are really
   just two basic cases: a) we create a hyperlink that only shows the DOI itself(
   for styles that use ‘doi:’, ‘doi: ‘, or only the bare DOI), or b) a hyperlink
   that shows the link text as well ([https://doi.org/](https://doi.org/)). In the
   latter case, if the style presents [http://doi.org/](http://doi.org/), I see 
   no reason why ZP shouldn’t output https anyway, but maybe there is a reason.
 * Here is the suggested code:
 *     ```wp-block-code
       				// Hyperlink DOIs				if ( isset($item->data->DOI)						// && $item->data->DOI !== null						&& strlen($item->data->DOI) > 0 )				{					// Styles without link text +					if ( strpos( $item->bib, "doi.org" ) == false )					{         				$item->bib = str_ireplace(   								$item->data->DOI,   								"<a class='zp-DOIURL' ".$zp_target_output."href='https://doi.org/".$item->data->DOI."'>".$item->data->DOI."</a>",   								$item->bib   							);     				}					// Styles with http or https					elseif ( strpos( $item->bib, "doi.org/" ) !== false                            && strpos( $item->bib, "</a>" ) == false )					{         				$item->bib = preg_replace(   								"#https?://doi.org/\S+#i",   								"<a class='zp-DOIURL' ".$zp_target_output."href='https://doi.org/".$item->data->DOI."'>https://doi.org/".$item->data->DOI."</a>",   								$item->bib   							);					}				}
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Please explain DOI hyperlinking’ is closed to new replies.

 * ![](https://ps.w.org/zotpress/assets/icon-256x256.png?rev=1995512)
 * [Zotpress](https://wordpress.org/plugins/zotpress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/zotpress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/zotpress/)
 * [Active Topics](https://wordpress.org/support/plugin/zotpress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/zotpress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/zotpress/reviews/)

 * 2 replies
 * 1 participant
 * Last reply from: [Jim](https://wordpress.org/support/users/jwmc/)
 * Last activity: [1 year, 3 months ago](https://wordpress.org/support/topic/please-explain-doi-hyperlinking/#post-18309152)
 * Status: not resolved