<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vasilis Baimas</title>
    <description>The latest articles on DEV Community by Vasilis Baimas (@vbaimas).</description>
    <link>https://dev.to/vbaimas</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F109966%2Fdb9bf5d0-9c4e-423b-81a2-026d559a86a0.jpeg</url>
      <title>DEV Community: Vasilis Baimas</title>
      <link>https://dev.to/vbaimas</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vbaimas"/>
    <language>en</language>
    <item>
      <title>Retrieve the permalink for a page and post type.</title>
      <dc:creator>Vasilis Baimas</dc:creator>
      <pubDate>Wed, 18 Sep 2019 09:43:26 +0000</pubDate>
      <link>https://dev.to/vbaimas/retrieve-the-permalink-for-a-page-and-post-type-l4</link>
      <guid>https://dev.to/vbaimas/retrieve-the-permalink-for-a-page-and-post-type-l4</guid>
      <description>&lt;p&gt;Do you know that the WordPress have some useful functions to link page and archive page? Let's see them in action.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario :&lt;/strong&gt; &lt;br&gt;
You would normally grab a page link via its ID but in the case that you had a localhost which install and an online install the ID was different, how you can link the page?&lt;/p&gt;
&lt;h2&gt;
  
  
  Get the permalink for a page by title
&lt;/h2&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="&amp;lt;?php echo get_permalink( get_page_by_title( 'about' ) ); ?&amp;gt;"&amp;gt;About Me&amp;lt;/a&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Get the permalink for a page by name
&lt;/h2&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="&amp;lt;?php echo get_permalink( get_page_by_path( 'About' ) ) ?&amp;gt;"&amp;gt;About Me&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Get the permalink for a page by slug
&lt;/h2&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="&amp;lt;?php echo get_permalink( get_page_by_path( 'about' ) ); ?&amp;gt;"&amp;gt;About Me&amp;lt;/a&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Get the permalink for a page by parent/child
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Scenario :&lt;/strong&gt; &lt;br&gt;
If you want to get the permalink using the method with child-page, then you need to pass the full slug. So, in this case we have a child page "about" with a parent pages which called "skills".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="&amp;lt;?php echo get_permalink( get_page_by_path( 'about/skills' ) ) ?&amp;gt;"&amp;gt;Skills&amp;lt;/a
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Get the link to custom post type archive page
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Scenario :&lt;/strong&gt; &lt;br&gt;
If you have a custom posts loop and in the bottom you want to add "View all" link, then how you should lead to the page with all posts that type?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;a href="&amp;lt;?php echo get_post_type_archive_link ( 'your_post_type' ) ?&amp;gt;"&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
In case that &lt;code&gt;get_post_type_archive_link()&lt;/code&gt; returns &lt;code&gt;false&lt;/code&gt;, make sure that you have used the argument &lt;code&gt;has_archive =&amp;gt; true&lt;/code&gt; when using &lt;code&gt;register_post_type()&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>development</category>
      <category>permalinks</category>
    </item>
  </channel>
</rss>
