komal deep singh chahal
komal deep singh chahal

Reputation: 1259

How to give hyperlink in wordpress

I am writing code in my wordpress themes folder. 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. Can anybody help me with this.

Thanks in advance

Upvotes: 3

Views: 1067

Answers (3)

Mukesh Ram
Mukesh Ram

Reputation: 6338

You have to use full path for that link, so, that would be 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.

You can read more about site_url

Upvotes: 1

vrajesh
vrajesh

Reputation: 2942

Try this :

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

Another way is to create template in wordpress theme folder

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

Upvotes: 1

Garry Gonzales
Garry Gonzales

Reputation: 51

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

See this url -> https://developer.wordpress.org/reference/functions/bloginfo/

Upvotes: 0

Related Questions