Remove slashes (both before and after) in relative post url

It’s because you’re not actually putting the result of ltrim() and rtrim() back into the variable. Those functions return the trimmed value, they don’t modify the passed variable. So you need to do this: $post_url_rel = wp_make_link_relative(get_permalink( $post_id )); $post_url_rel = ltrim($post_url_rel, “https://wordpress.stackexchange.com/”); $post_url_rel = rtrim($post_url_rel, “https://wordpress.stackexchange.com/”); Or better yet, just use trim(), which will … Read more

Clean URL link for page without number

This is because your site already has a post or page (6 in your case) with the slug “photo.” They might be in the trash, or pending as drafts, or whatever … but WordPress automatically appends number to prevent name conflicts. So go through your site, and figure out which other pages are trying to … Read more

Using a portfolio_category slug in wordpress URL

add ‘rewrite’ => array(‘slug’ => ‘portfolio-categories’), but be sure to remove (not sure why that’s there, it tries hides the slug yet tries to rename it to “products” at the same time?): ‘rewrite’ => array( ‘with_front’ => false, ‘slug’ => ‘products’ ), So it looks like this: function mysite_post_types() { register_post_type(‘portfolio’, array( ‘labels’ => array( … 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.

Site URL always in front of other URLs

You need to start your links with http:// Examples: The link facebook.com/mypage becomes http://facebook.com/mypage The link www.commentorsite.com/ becomes http://www.commentorsite.com/ This will stop the links becoming http://mysite.com/www.commentorsite.com/ or http://mysite.com/facebook.com/mypage

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