WordPress - 将主页标题拉入面包屑的任何其他页面

WordPress - Pull In HomePage Title To Any Other Page For Breadcrumb

我已经在我的网站上设置了面包屑导航,现在由于想将 WPML 集成到网站中,我不能再留下带有硬编码名称的主页面包屑导航。

谁能告诉我如何从首页/静态页面(主页)提取标题?

我有以下代码:

echo '<li><a href="'. get_settings('home') .'">Home</a> > </li>';

但我无法在说明如何执行此操作的文档中找到任何内容。

感谢您的宝贵时间和帮助。

你指的是首页还是首页?无论哪种方式,它都将是 get_options.

的变体

检查手抄本。

获取首页 ID:https://codex.wordpress.org/Function_Reference/get_option#Parameters

通过 ID 获取页面标题:https://codex.wordpress.org/Function_Reference/get_the_title

首页

echo '<li><a href="'. get_settings('home') .'">Home</a>'.get_the_title(get_option('page_on_front')).'</li>';

博客页面

echo '<li><a href="'. get_settings('home') .'">Home</a>'.get_the_title(get_option('page_for_posts')).'</li>';