{"id":942,"date":"2015-09-07T08:26:26","date_gmt":"2015-09-07T08:26:26","guid":{"rendered":"http:\/\/www.nikola-breznjak.com\/blog\/?p=942"},"modified":"2015-09-07T08:26:26","modified_gmt":"2015-09-07T08:26:26","slug":"how-to-add-logout-link-to-wordpress-woocommerce","status":"publish","type":"post","link":"https:\/\/nikola-breznjak.com\/blog\/wordpress\/how-to-add-logout-link-to-wordpress-woocommerce\/","title":{"rendered":"How to add Logout link to WordPress WooCommerce"},"content":{"rendered":"<p>First, find the text that says something like <strong>Login<\/strong> or <strong>register<\/strong>. A tool like <a href=\"http:\/\/astrogrep.sourceforge.net\/\">AstroGrep<\/a>, if you&#8217;re on Windows, may be of great help if you don&#8217;t know in which file you have to look (like I didn&#8217;t).<\/p>\n<p>Then you will most probably see something like this:<\/p>\n<pre class=\"lang:default decode:true\">&lt;div class=\"account_links\"&gt;\r\n\t&lt;?php if ( is_user_logged_in() ) : ?&gt;\r\n\t\t&lt;a href=\"&lt;?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?&gt;\" title=\"&lt;?php _e('My Account','wpdance'); ?&gt;\"&gt;Mein Konto&lt;\/a&gt;\r\n\t&lt;?php else : ?&gt;\r\n\t\t&lt;a href=\"&lt;?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?&gt;\" title=\"&lt;?php _e('Login','wpdance'); ?&gt;\"&gt;Anmelden&lt;\/a&gt;\r\n\t\t&lt;span&gt;oder&lt;\/span&gt;\r\n\t\t&lt;a href=\"&lt;?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?&gt;\" title=\"&lt;?php _e('Create An Account','wpdance'); ?&gt;\"&gt;registrieren&lt;\/a&gt;\r\n\t&lt;?php endif; ?&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>In the <strong>is_user_logged_in()<\/strong> part of the <strong>if<\/strong> add the following statement:<\/p>\n<pre class=\"lang:default decode:true \">&lt;a href=\"&lt;?php echo wp_logout_url( get_permalink( woocommerce_get_page_id( 'myaccount' ) ) );?&gt;\"&gt;Logout&lt;\/a&gt;<\/pre>\n<p>so that the final code then looks like this:<\/p>\n<pre class=\"lang:default decode:true \">&lt;div class=\"account_links\"&gt;\r\n\t&lt;?php if ( is_user_logged_in() ) : ?&gt;\r\n\t\t&lt;a href=\"&lt;?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?&gt;\" title=\"&lt;?php _e('My Account','wpdance'); ?&gt;\"&gt;Mein Konto&lt;\/a&gt;\r\n\t\t&lt;span&gt; | &lt;\/span&gt;\r\n\t\t&lt;a href=\"&lt;?php echo wp_logout_url( get_permalink( woocommerce_get_page_id( 'myaccount' ) ) );?&gt;\"&gt;Logout&lt;\/a&gt;\r\n\t&lt;?php else : ?&gt;\r\n\t\t&lt;a href=\"&lt;?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?&gt;\" title=\"&lt;?php _e('Login','wpdance'); ?&gt;\"&gt;Anmelden&lt;\/a&gt;\r\n\t\t&lt;span&gt;oder&lt;\/span&gt;\r\n\t\t&lt;a href=\"&lt;?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?&gt;\" title=\"&lt;?php _e('Create An Account','wpdance'); ?&gt;\"&gt;registrieren&lt;\/a&gt;\r\n\t&lt;?php endif; ?&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>This is it for this quick tip, hope it helps someone. I&#8217;ll keep it for reference for when I can&#8217;t remember it straight away&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>First, find the text that says something like Login or register. A tool like AstroGrep, if you&#8217;re on Windows, may be of great help if you don&#8217;t know&hellip;<\/p>\n","protected":false},"author":1,"featured_media":2173,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"class_list":["post-942","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress"],"_links":{"self":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/942","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/comments?post=942"}],"version-history":[{"count":2,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/942\/revisions"}],"predecessor-version":[{"id":2174,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/942\/revisions\/2174"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/media\/2173"}],"wp:attachment":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/media?parent=942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/categories?post=942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/tags?post=942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}