Tag Info

New answers tagged

1

Another safer alternative to this problem is using get_queried_object() which holds the current queried object to get the page slug which is held by the post_name property. This can be used anywhere in your template. $post can be used, but it can be unreliable as any custom query or custom code can change the value of $post, so it should be avoided outside ...


1

As per other answers slug is stored in post_name property. While it could be accessed directly I prefer the (underused) get_post_field() function for access post properties which have no proper API for them. It requires post provided explicitly and doesn't default to the current one, so in full for current post it would be: $slug = get_post_field( ...


0

Set permalink to (Post Name) or http://www.example.com/[blog_name]`/%post_id%/%postname%/` Add following code to functions.php of your theme: add_filter ( 'alias_rule', 'xili_language_trans_slug_qv' ) ; function xl_permalinks_init () { global $XL_Permalinks_rules; if (class_exists('XL_Permalinks_rules') ) { $XL_Permalinks_rules = new ...


0

Ok, after a little playtime, here is the answer: add_action('save_post', 'ocp_jobs_save_details'); function ocp_jobs_save_details(){ global $post; $genref = sanitize_title( dechex( time() ) ); if ( $post->post_type == 'job' ) { if ( $_POST['ocp_jobs_ref'] ) { $jobs_args = array( 'ID' => $post->ID, 'post_name' => strtolower( ...


0

First: I feel the need to ask where exactly are you putting this php code? Hopefully not in the content area of the page through the WordPress Dashboard as php does not work there. (This is the "is it plugged in?" question that needs to be asked first.) You must put all php code inside a .php file in your theme somewhere. Don't feel insulted or stupid, it ...


0

this should work <?php echo do_shortcode('[shortcode_products_by_brand title="Promozioni" per_page="12" columns="4" orderby="title" order="desc" brand="'. $entity->getSlug() .'" operator="IN"]') ?>


1

I know this is an old post, but I think there is wrong information here. I was having conflicts with slugs between different custom post types and taxonomies and decided to do some reading about it to understand it better. I am using WordPress 4.2.2, and I am able to create different posts types with the same slug. Apparently this is a known issue being ...


0

I am not sure what are you trying to get here: Sabai::_h($entity->getSlug()); but Since you are echoing a statement, you need to store the value in a variable first and then call it within the shortcode string. <?php $brand_variable = Sabai::_h($entity->getSlug()); echo do_shortcode('[shortcode_products_by_brand title="Sample brand products" ...


0

Just of the top of my head, something along this way might work: function wpse178647_rewrite() { add_rewrite_rule( '^([^/]+)/([^/]+)/?$', '' 'index.php?category_name=$matches[1]&pagename=$matches[2]', 'top' ); } add_action( 'init', 'wpse178647_rewrite' ); Completely and utterly untested.


1

After some brainstorming and a lot of trial and error with T5 Rewrite and HM Rewrite, I went for the simplest possible solution. The permalink was actually intercepted by WordPress so I didn't need the additional rewrite rule (even though it didn't hurt, other than performance). I left %category%/%post_id%/%postname% as the default custom permalink, and it ...



Top 50 recent answers are included