Prevent WordPress from abbreviating-long-slugs…-in-the-admin

There is a filter at the end of the function: ‘get_sample_permalink_html’. Hook into this and just replace the shortened form with the full length. <?php # -*- coding: utf-8 -*- /* Plugin Name: T5 Unabridge Permalink Slug */ add_filter( ‘get_sample_permalink_html’, ‘t5_unabridge_sample_permalink’, 10, 2 ); /** * Replaces the shortened permalink with its full form. * … Read more

Meta_Query as a way how to setup CPT permalinks – is it a good thing?

Since it is a performance question, you might be able to avoid using meta keys at all by storing/getting that data another way and not having to set a separate meta field to match with… a. You could get the year from the published $post->post_date… So that when doing the query just use the date … Read more

Rewriting every url

There’s not a good way to prepend a permalink with a URI base that I know of and keep WordPress happy at the same time. You can however add the language to the end of the URI with add_rewrite_endpoint(); add_action(‘init’, ‘foobar_rewrite_tag’); function foobar_rewrite_tag(){ $languages = array(‘en’, ‘sp’); // Probably have this sourced from your plugin … Read more

How can I store page ID in a post instead of other selected permalink?

Add that to your functions.php: function wp_link_query_mod ( $results ){ if( count( $results ) ){ for( $i=0; $i<count($results); $i++ ){ $results[$i][‘permalink’] = wp_get_shortlink( $results[$i][‘ID’] ); } } return $results; } add_filter(‘wp_link_query’, ‘wp_link_query_mod’); This hook is only usable since WP 3.7, if you have an earlier version then there is an alternative but it would mean … Read more

Change slug on post creation

Here is what I did to implement this: function slug_save_post_callback( $post_ID, $post, $update ) { // allow ‘publish’, ‘draft’, ‘future’ if ($post->post_type != ‘post’ || $post->post_status == ‘auto-draft’) return; // only change slug when the post is created (both dates are equal) if ($post->post_date_gmt != $post->post_modified_gmt) return; // use title, since $post->post_name might have unique … Read more

Custom post type permalink: only use %post_id% and remove %postname%

I found the answer myself – so here is the update to above problem: Custom post type registration: function create_post_type_mycustomname() { $args = array( ‘capability_type’ => ‘post’, ‘has_archive’ => ‘mycustomname’, ‘rewrite’ => array( ‘slug’ => ‘/mycustomname’, ‘feeds’ => false ) ); register_post_type(‘ctp_mycustomname’, $args); } add_action(‘init’, ‘create_post_type_mycustomname’); Change the links: function mycustomname_links($post_link, $post = 0) { … Read more

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