我在我的网站上设置了一个痕迹,现在由于想要将WPML集成到网站中,我不能再使用硬编码名称留下主页痕迹了 .
谁能告诉我如何从前/静态页面(主页)中提取 Headers ?
我有以下代码:
echo '<li><a href="'. get_settings('home') .'">Home</a> > </li>';
但我无法在文档中找到解释如何执行此操作的任何内容 .
感谢您的时间和帮助 .
你的意思是主页还是头版?无论哪种方式,它都将是 get_options 的变体 .
get_options
检查手抄本 .
获取首页ID:https://codex.wordpress.org/Function_Reference/get_option#Parameters
按ID获取页面 Headers :https://codex.wordpress.org/Function_Reference/get_the_title
Front Page
echo '<li><a href="'. get_settings('home') .'">Home</a>'.get_the_title(get_option('page_on_front')).'</li>';
Blog Page
echo '<li><a href="'. get_settings('home') .'">Home</a>'.get_the_title(get_option('page_for_posts')).'</li>';
1 回答
你的意思是主页还是头版?无论哪种方式,它都将是
get_options
的变体 .检查手抄本 .
获取首页ID:https://codex.wordpress.org/Function_Reference/get_option#Parameters
按ID获取页面 Headers :https://codex.wordpress.org/Function_Reference/get_the_title
Front Page
Blog Page