Custom Permalinks don’t work on local LAMP installation

I had the same problem. It sounds like you don’t have rewrites turned on in your installation. Find your httpd.conf file, find the following line: #LoadModule rewrite_module modules/mod_rewrite.so And remove the # at the beginning so it looks like this: LoadModule rewrite_module modules/mod_rewrite.so Save and then restart the service. Custom Permalinks should now work. There … Read more

Get closest page ID from URL

You should be able to get the current url from $url = add_query_arg(). Then assuming, the structure: www.example.com/page/subpage/news/ID/post you can use preg_match to extract /page/subpage/news. Then it would be simple matter of using get_page_by_path();. If that fails you can then check /page/subpage/ and finally /page.

Confusion about how a URL is being parsed

WordPress uses set of regular expressions to parse urls (so called rewrite rules). It matches them in some order and stops when first matching rule is found. It’s a little bit hard to say what rule is matched in your case. We don’t know what are your permalink settings and what other changes to rewrite … Read more

Best way to add internal link in widget

The page ID can vary in different installation, and it can’t be changed, so an option is to use get_page_by_path because the page slug can be easily changed: <div class=”my-link-box”> <?php $page = get_page_by_path(‘my-page’); ?> <a href=”https://wordpress.stackexchange.com/questions/126876/<?php echo get_permalink($page); ?>”><?php echo $page->post_title; ?></a> </div> However this is not a great solution as well. Once you … Read more

Get canonical link

Since WP 4.6 there has been a core function for this: wp_get_canonical_url() Call it with a post ID to get that post’s canonical URL, or in the loop without a post ID to get the current post’s canonical URL.

How to tranform Headlines into linkable permalinks?

Analysed situation When you take a look at your (original) example “GitHub” and it’s source code, you see the following: <a name=”updating-submodules” class=”anchor” href=”#updating-submodules”> <span class=”octicon octicon-link”></span> </a> Prerequisites Basically this is possible (even pretty easy), but you’ll have to have theme templates that properly use WordPress Templates Tags. The functions that are needed are … Read more

Link to external URL

Without http:// in front, your code won’t work. You will need to add that infront. You can make use of parse_url to add http:// to urls that does not have that. To make this protocol agnostic, you can simply use // You can try something like this $urlStr=”www.google.com”; $parsed = parse_url($urlStr); if ( empty( $parsed[‘scheme’] … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)