简体   繁体   English

如何在wordpress中给出超链接

[英]How to give hyperlink in wordpress

I am writing code in my wordpress themes folder. 我正在我的wordpress主题文件夹中编写代码。 i am giving hyperlink to another page from my index page but its not working. 我正在从我的索引页面给出另一个页面的超链接,但它不起作用。

     <li><a href="admin/admin.php"> Admin </a></li>

Link is not working like this 链接不是这样的

I am new to wordpress. 我是wordpress的新手。 Can anybody help me with this. 任何人都可以帮助我。

Thanks in advance 提前致谢

Try this : 试试这个 :

<a href="<?php bloginfo('template_url'); ?>/admin.php">Admin</a>

Another way is to create template in wordpress theme folder 另一种方法是在wordpress主题文件夹中创建模板

<?php
/*
Template Name: templatename
*/
?>

You have to use full path for that link, so, that would be http://site-url/slug . 你必须使用该链接的完整路径,因此,这将是http:// site-url / slug You can achieve that by using following code. 您可以使用以下代码实现此目的。

<li><a href="<?php echo site_url();?>/admin/admin.php"> Admin </a></li>

The site_url template tag retrieves the site url for the current site (where the WordPress core files reside) with the appropriate protocol, 'https' if is_ssl() and 'http' otherwise. site_url模板标记使用适当的协议检索当前站点(WordPress核心文件所在的站点)的网站URL,如果是is_ssl()则检索“https”,否则检索“http”。

You can read more about site_url 您可以阅读有关site_url的更多信息

You need to use the full path. 您需要使用完整路径。

In order to get url of the home page, 为了获得主页的网址,

use this. 用这个。

<a href="<?php bloginfo('site_url'); ?>/admin">Admin</a>

to get file use this. 获取文件使用此。

<a href="<?php bloginfo('template_url'); ?>/admin/admin.php">Admin</a>

For more information about the bloginfo 有关bloginfo的更多信息

See this url -> https://developer.wordpress.org/reference/functions/bloginfo/ 请参阅此URL - > https://developer.wordpress.org/reference/functions/bloginfo/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM