Disable permalink on custom post type

<?php add_filter(‘get_sample_permalink_html’, ‘my_hide_permalinks’); function my_hide_permalinks($in){ global $post; if($post->post_type == ‘my_post_type’) $out = preg_replace(‘~<div id=”edit-slug-box”.*</div>~Ui’, ”, $in); return $out; } This will remove: Permalink itself View Post button Get Shortlink button If you want to remove permalink only, replace the line containing preg_replace with $out = preg_replace(‘~<span id=”sample-permalink”.*</span>~Ui’, ”, $in); UPDATE: get_sample_permalink_html has changed in version … Read more

Custom Post Types, slug, archive and SEO plugins

I don’t know what content you want to insert in your archive page, but you can always use the file “archive-friends.php” as you can see in the Template Hierarchy to loop your “friends” post type. Then, to customize the SEO, I recommend you the plugin WordPress SEO by Yoast because it has a strong compatibility … Read more

Change the author slug from nickname to ID

Surprised to see this unanswered for this long. This is pretty simple to do with a simple block of code: function set_my_nice_name() { global $wpdb; $user_table = $wpdb->prefix . ‘users’; $wpdb->query(“UPDATE $user_table SET `user_nicename`=`ID`”); } add_action(‘init’, ‘set_my_nice_name’); This works because the visible portion of an author slug (or profile slug in BuddyPress) uses the user_nicename … Read more

What is wp_insert_term “alias_of” arg for?

In the Code Reference it says: ‘alias_of’ (string) Slug of the term to make this term an alias of. Default empty string. Accepts a term slug. This makes a term an alias of another term. Using your example this is how you would use it: wp_insert_term( ‘e’, ‘tax’, array( ‘alias_of’ => ‘a’ ) ); This … Read more

Rename files during upload using variables

You’ll want to hook in to the wp_handle_upload_prefilter filter (which I can’t find any documentation on, but seems pretty simple). I’ve tried this out locally, and it seems to work for me: function wpsx_5505_modify_uploaded_file_names($arr) { // Get the parent post ID, if there is one if( isset($_REQUEST[‘post_id’]) ) { $post_id = $_REQUEST[‘post_id’]; } else { … Read more

Custom Post type & Taxonomy URL structure

After forever, I figured out an answer! First: we register the custom post type & custom taxonomy: add_action( ‘init’, ‘register_sps_products_post_type’ ); function register_sps_products_post_type() { register_post_type( ‘sps-product’, array( ‘labels’ => array( ‘name’ => ‘Products’, ‘menu_name’ => ‘Product Manager’, ‘singular_name’ => ‘Product’, ‘all_items’ => ‘All Products’ ), ‘public’ => true, ‘publicly_queryable’ => true, ‘show_ui’ => true, ‘show_in_menu’ … Read more

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