0

Converting my HTML template to WP Theme I am confused how to linkto the pages in WP? For Example I have an Item div which I would like to link to my store page when user click on that but I dont know how to get the correct URL for my store page?! This is also happening when I would like to link from another site to my page for example how I can link to my page from here?
http//www.ghazalphoto.portfolio.html Or
http//www.ghazalphoto.portfolio.php Or
http//www.ghazalphoto.portfolio

2 Answers 2

0

Use this to output correct link:

<?php 
   $page = get_page_by_title( 'Store' );
   echo get_permalink( $page );
?>

Or if you know ID of your page (you can get ID from administration), you can use just (if ID is 2)

<?php echo get_permalink( 2 ); ?>

You can read more about get_permalink function here

And I would also suggest you to read something about wp_nav_menu function to enable your theme to use Navigation menus.

0

When you create a page in wordpress it works like a template in your case to create a portfolio page you need to create a page-portfolio.php file in your theme folder.

Add on first line:

 <?php
 /*
 Template Name: Portfolio Page
 */
 ?>

Build your portfolio page here. Create a page in Administration-> Pages-> Add New. Select 'Portfolio Page' from drop down on right side. Publish and take note of the now live URL.

In WordPress you can link in the code like:

<a href="portfolio pages live link"<div>Link to Portfolio Page</div></a>
// or
<a href="<?php $page = get_page_by_title( 'Behseinis Page' );echo get_permalink( $page ); ?>">
<div>Link to Portfolio Page</div></a>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.