If you would like to talk about your project call (02) 4474 5861

Linking to a page within a WordPress theme file

If you are wanting to create a page link from within a WordPress custom template file and want it to be flexible and not hard coded while also not having to write out the full url in the a link reference then you could look at using “get_template_directory_uri”.

For example:

<a href="<?php get_template_directory_uri(); ?>/design">Design Services</a>

If you where just using

<?php bloginfo('url'); ?>
then this would link back to the homepage/url address of your website, no matter where your WordPress was installed such as in a sub folder or at the root level.

Two good follow up point to read about are: bloginfo() and Referencing Files From a Template from the WordPress Codex.

Codex does highlight to use

<?php get_template_directory_uri(); ?>
then the above which will also return a relative trail though when using echo like this

<?php echo get_template_directory_uri(); ?>
it will return a hard-coded url (to that of the site url).

Do more homework on from Codex: Consider echoing get_template_directory_uri() instead (for the parent template directory) or get_stylesheet_directory_uri() (for the child template directory).

Instinctively creative & thoughtful strategies with result orientated outcomes

Visually communicating effectively with your potential & current customers adds to the good business experience.

BJ2DESIGN combines a wealth of design knowledge with creative business strategies to create result oriented work.

Read More About BJ2DESIGN

creative hand and tools