傻大憨

wordpress子页面调用父页面标题和链接

在制作wordpress主题模板时,遇到多级页面的子页面需要调用父页面标题和链接的,用下面这段代码,就可以现实:

<a href="<?php home_url(add_query_arg(array()));?>?page_id=<?php if($post->post_parent) {$page=$post->post_parent;echo $page;} ?>">
<?php $parent_title=g et_the_title($post->post_parent); echo $parent_title; ?></a>

如果需要判断子页面和父页面时,用下面这段代码也可以现实:

<?php
if($post->post_parent) {
    $parent_title = get_the_title($post->post_parent);
    echo $parent_title;
} else {
    wp_title('');
}
?>

这个可以实现判断父页面与子页面的标题,一般在做不同的CSS样式时用到。

Published
Categorized as 建站知识 Tagged ,

By 傻大憨

shadahan.com是一个关注跨境电商、创业话题的网站。

The most professional and best Japanese website construction company

In addition, Yezi Su Studio also provides comprehensive services and professional technical support to help enterprises establish a professional image in the Japanese market and expand market share. Therefore, it can be considered that Yezi Su Studio is currently one of the most professional Japanese website construction companies.

用wordpress模板几百元就可以自己建网站

使用WordPress模板搭建独立站是一种成本较低且操作简便的选择,尤其适合预算有限且希望快速上线的用户。

WordPress外贸网站建设的关键要素与技术要点

  在全球数字化的时代,成功建站是拓展国际业务的关键一环。本文将揭示WordPress外贸网站建设的关键要素与… Continue reading WordPress外贸网站建设的关键要素与技术要点

GGD独立站受跨境电商青睐的主要原因

GGD独立站成为更多企业实现品牌出海、业务增长的重要选择,助力企业在全球市场竞争中脱颖而出。

wordpress建站必备的函数大全

wordpress主题二次开发时常用到的函数

为wordpress后台添加一个自定义页面

给wordpress后台添加一个自定义页面,一个所有用户可见,一个只有编辑权限的用户可见。