generate custom permalink based on a custom field

Try this plugin Custom Post Type Permalinks, it allows you to set permalinks for custom post types. If your client does not want additional plugin then this plugin is also available on GitHub you can fork it or include this functionality in your own plugin or your functions.php. In order to use anything dynamic in … Read more

Gutenberg Editor: dynamicaly change slug field with an ACF field

I’ve found a way to dynamicaly change the slug field with the short title custom field. jQuery(document).ready(() => { const acfField = ‘field_61f8bacf53dc5’; const inputShortTitle = document.getElementById(‘acf-‘ + acfField); const slugify = (str) => { return str.toLowerCase().replace(/ /g, ‘-‘) .replace(/-+/g, ‘-‘).replace(/[^\w-]+/g, ”); } const updateSlug = () => { wp.data.dispatch(‘core/editor’).editPost({slug: slugify(inputShortTitle.value)}); } if (inputShortTitle !== … Read more

How to get blog id from permalink?

the plugin “WDS Multisite Aggregate” store the blog identifier in a meta of the cloned post. then in the template file wich display the cloned posts, you can retrieve the home url of the original website with that : $blogid = $GLOBALS[“post”]->blogid; $blog_details = get_blog_details($blogid); // the home URL is in $blog_details->home I hope this … Read more

Rewrite rule never matching

Please try this. First add the rewrite rule you need with this function add_action( ‘init’, ‘rewrite_site_tools_page’ ); function rewrite_site_tools_page() { add_rewrite_rule( ‘^site-tools-([^/]+)$’, ‘index.php?pagename=site-tools&tool=$matches[1]’, ‘top’); } Assuming that page name is site-tools. Now add the tool as query var add_filter(‘query_vars’, ‘wpd_query_vars’); function wpd_query_vars( $query_vars ){ $query_vars[] = ‘tool’; return $query_vars; } Save permalinks. Now if you … Read more

remove permalink trailing slash

You can use the trim command to do this, specifically, the rtrim to remove the character from the right side: $url = rtrim(get_permalink(),”https://wordpress.stackexchange.com/”); Using a blanket substr -1 technique would cause problems if there isn’t a trailing slash in the permalink. Also, the function the_permalink echoes the link, and get_permalink returns it as a string.

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