How to call the rewrite slug in an Oxygen template

[ad_1]

Hello,
I am using Oxygen builder and when I call the post type name it doesn’t show the “rewrite” slug, but the actual one.

I guess this is because Oxygen uses the standard get_post_type function from WordPress ) to get the post type.

I have tried then to use a function like this:

<?php

if(!function_exists('oxys_get_rewrite_slug')) {
	function oxys_get_rewrite_slug() {
		$post_type = get_post_type();
		if($post_type) {
			$post_type_object = get_post_type_object( $post_type );
			$rewrite_slug     = $post_type_object->rewrite['slug'];

			echo $rewrite_slug;
		}
	}
}
?>

but it doesn’t work and I am not a coder, so I am pretty blind here…
the Oxygen template allows inserting dynamic data using a “PHP function return value”, the option it has 2 fields where it asks for the function name and for the function arguments separated by comma.

First I have inserted the function as a code snippet,
the name is
oxys_get_rewrite_slug
but the arguments… ?

ChatGTP says there are none, it tried to give a me a bunch of alternatives but none of them works. So back to asking human beings 🙂

Thanks for any help

  • This topic was modified 1 hour, 40 minutes ago by Kyrian.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer