Mapping Domains to Permalinks (not multisite)

If you set domain.com as an alias of original.com, in WordPress you have to do nothing to make it works. The problem is the countrary: once in DNS the 2 domains are aliases, every url of your WordPress will be accessible via user defined domains: domain.com/any/wp/url, but also domain2.com/any/wp/url, domain3.com/any/wp/url and so on… So, what … Read more

How to Check if a Page Exists by URL?

You could make a list of paths to check… $page_paths = array( ‘analysis/firstNamelastName’, ‘exercise/firstNamelastName’ ); Then check if there’s a page object for each of the page paths. foreach( $page_paths as $page_path ) { echo ‘<code>’ . $page_path . ‘</code> ‘ . PHP_EOL; if( ! $page = get_page_by_path( $page_path ) ){ echo ‘Does not exist.’ … Read more

How to get permalinks with category base working with sub-categories

I was able to get this to work pretty easily actually. I am now able to have my category base in my permalinks. This allows me to now have URLs like: http://www.new1450.dev/industries/ {Main blog post only showing category selection} http://www.new1450.dev/industries/development/ {a parent category} http://www.new1450.dev/industries/development/parent-category-i/ {child of parent} http://www.new1450.dev/industries/development/parent-category-i/child-category-i/ {child of child} http://www.new1450.dev/industries/development/parent-category-i/child-category-i/some-cool-post/ {actual post} This … Read more

How can I reverse engineer a Permalink to Find the Page?

Addressing both your original question and the question implied by your comment … Finding the page ID Every post and page within WordPress is given an ID. By default, WordPress uses the ID in the link structure: http://www.example.com/?page=ID or http://www.example.com/?p=ID (for posts). You can change this to a more user-friendly structure called “pretty permalinks” that … Read more

How can I make Capital letter ( upper-case ) permalinks?

The page URLs are defined by the slugs, and by default they are formatted and lower-cased by the function sanitize_title_with_dashes(). However, this function is called via a filter, and you can unhook the filter so it doesn’t get called: remove_filter( ‘sanitize_title’, ‘sanitize_title_with_dashes’ ); Just doing this is probably not a good idea, as it will … Read more

Disable Attachment Pages Completely

You can filter default rewrite rules and remove those for attachments: function cleanup_default_rewrite_rules( $rules ) { foreach ( $rules as $regex => $query ) { if ( strpos( $regex, ‘attachment’ ) || strpos( $query, ‘attachment’ ) ) { unset( $rules[ $regex ] ); } } return $rules; } add_filter( ‘rewrite_rules_array’, ‘cleanup_default_rewrite_rules’ ); Don’t forget to … Read more

How to call a plugin function from index.php

The same way you would any other: foo(); Active plugins are loaded before the theme files You may want to check that your plugin is activated and the function is available so things dont go pear-shaped if you forget to activate it, like: if(function_exists(‘foo’)){ foo(); } else { echo “oh dear you haven’t activated/installed ‘myplugin’, … Read more

Custom post type permalink endpoint

A couple things. First, your function names need to be prefixed with something unique. WordPress is a big ecosystem, and someone else has probably used all the generic function names you can think of. Second, add_rewrite_endpoint takes care of adding query variables for you. So you don’t need this: add_filter( ‘query_vars’, ‘add_query_vars’); function add_query_vars($vars){ $vars[] … Read more

Hide permalink and preview button and link on custom post

You can accomplish the above using hooks. Use the code below in your active theme’s functions.php file to get this work delete permalink under wordpress post title add_filter( ‘get_sample_permalink_html’, ‘wpse_125800_sample_permalink’ ); function wpse_125800_sample_permalink( $return ) { $return = ”; return $return; } Customizing post link from original wordpress add_filter( ‘page_row_actions’, ‘wpse_125800_row_actions’, 10, 2 ); add_filter( … Read more

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