$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>How to add custom PHP code in post header?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

How to add custom PHP code in post header?

matteradmin9PV0评论

In header.php i want to add :

1. For home page :

link rel="alternate" href="/fr/" hreflang="fr-FR"

2. For custom single post :

link rel="alternate" href="/fr/category/post-name/" hreflang="fr-FR"

What code will be use for this ?

In header.php i want to add :

1. For home page :

link rel="alternate" href="/fr/" hreflang="fr-FR"

2. For custom single post :

link rel="alternate" href="/fr/category/post-name/" hreflang="fr-FR"

What code will be use for this ?

Share Improve this question edited Nov 1, 2018 at 11:45 Pratik Patel 1,1091 gold badge11 silver badges23 bronze badges asked Nov 1, 2018 at 7:34 Sunny K. UjjawalSunny K. Ujjawal 12 bronze badges 1
  • See here wordpress has some conditional tag that will help you to do what you want codex.wordpress/Conditional_Tags – mlimon Commented Nov 1, 2018 at 7:43
Add a comment  | 

1 Answer 1

Reset to default 0

Please try like

if ( is_front_page() || is_home() ) {
    //IF HOME PAGE
}

if ( is_singular('YOUR-CUSTOM-POST-TYPE-HERE') ) {
  // FOR SINGLE PAGE STUFF
}

Please make sure you have to replace YOUR-CUSTOM-POST-TYPE-HERE with your Custom post type.

Please let me know if any query.

Thanks!

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far