• I would like to use relative url on my website and for custom_post where I use permalink manager, wp_relative_link function (wp_relative_link) doesn’t work on post_type_link filter.
    Have you a solution?
    many thanks

Viewing 1 replies (of 1 total)
  • Plugin Author Maciej Bis

    (@mbis)

    Hi @manuf3c,

    I am not exactly certain what do you mean. I guess that you would like to replace all static links embedded directly to HTML code with some dynamic method, eg. shortcode?

    If yes, I would suggest to write a simple snippet/shortcode and use $permalink_manager_uris global, eg.

    function pm_dynamic_link($atts) {
    	global $permalink_manager_uris;
    
    	if(is_numeric($atts['id']) && !empty($permalink_manager_uris[$atts['id']])) {
    		$home_url = trim(get_option('home'), "/");
    		$post_uri = $permalink_manager_uris[$atts['id']];
    		return "{$home_url}/{$post_uri}";
    	} else {
    		return "#";
    	}
    }
    add_shortcode('relative-url', 'pm_dynamic_link');

    Then you can use relative permalinks as shortcodes, eg. [relative-url id="123"] instead of full permalinks.

    Regards,
    Maciej

Viewing 1 replies (of 1 total)
  • The topic ‘Relative url’ is closed to new replies.