Skip to main content
New code
Source Link
Jenny
  • 1.8k
  • 4
  • 26
  • 41

I want to modify $path in the following filter. It has 1 input and 2 args.

function documents_template( $template = '' ) {
    
       $path = DOCUMENTS_INCLUDES_DIR . '/document/' . $template;

  return apply_filters( 'document_template', $path, $template );
}

This is my function to add filter, it gets error message, how to get it right?

function my_template( $template = '' ){

      $path = MY_INCLUDES_DIR . '/document/'. $template;

     return $path;
}
add_filter( 'document_template','my_template', 10, 2 );

I tried to change my return value as following, it doesn't work either:

return apply_filters( 'my_template', $path, $template);

With the belowing answers, my new filter still not working, so, maybe it's because my filter is in a class? here's the completely new code:

Class My_Class{
  function __construct() {
     add_filter( 'document_template', array( $this, 'my_template',10, 2 ) );
  }
 function my_template( $path, $template ){

      $path = MY_INCLUDES_DIR . '/document/'. $template;

     return $path;
 }
}

I want to modify $path in the following filter. It has 1 input and 2 args.

function documents_template( $template = '' ) {
    
       $path = DOCUMENTS_INCLUDES_DIR . '/document/' . $template;

  return apply_filters( 'document_template', $path, $template );
}

This is my function to add filter, it gets error message, how to get it right?

function my_template( $template = '' ){

      $path = MY_INCLUDES_DIR . '/document/'. $template;

     return $path;
}
add_filter( 'document_template','my_template', 10, 2 );

I tried to change my return value as following, it doesn't work either:

return apply_filters( 'my_template', $path, $template);

I want to modify $path in the following filter. It has 1 input and 2 args.

function documents_template( $template = '' ) {
    
       $path = DOCUMENTS_INCLUDES_DIR . '/document/' . $template;

  return apply_filters( 'document_template', $path, $template );
}

This is my function to add filter, it gets error message, how to get it right?

function my_template( $template = '' ){

      $path = MY_INCLUDES_DIR . '/document/'. $template;

     return $path;
}
add_filter( 'document_template','my_template', 10, 2 );

I tried to change my return value as following, it doesn't work either:

return apply_filters( 'my_template', $path, $template);

With the belowing answers, my new filter still not working, so, maybe it's because my filter is in a class? here's the completely new code:

Class My_Class{
  function __construct() {
     add_filter( 'document_template', array( $this, 'my_template',10, 2 ) );
  }
 function my_template( $path, $template ){

      $path = MY_INCLUDES_DIR . '/document/'. $template;

     return $path;
 }
}
Tweeted twitter.com/#!/StackWordPress/status/160141689527349248
added 12 characters in body
Source Link
Jenny
  • 1.8k
  • 4
  • 26
  • 41

I want to modify $path in the following filter. It has 1 input and 2 args.

function documents_template( $template = '' ) {
    
       $path = DOCUMENTS_INCLUDES_DIR . '/document/' . $template;

  return apply_filters( 'document_template', $path, $template );
}

This is my function to add filter, it gets error message, how to get it right?

function my_template( $template = '' ){

      $path = MY_INCLUDES_DIR . '/document/'. $template;

     return $path;
}
add_filter( 'document_template','my_template', 10, 2 );

I tried to change my return value as following, it doesn't work either:

return apply_filters( 'my_template', $path, $template);

I want to modify $path in the following filter. It has 2 args.

function documents_template( $template = '' ) {
    
       $path = DOCUMENTS_INCLUDES_DIR . '/document/' . $template;

  return apply_filters( 'document_template', $path, $template );
}

This is my function to add filter, it gets error message, how to get it right?

function my_template( $template = '' ){

      $path = MY_INCLUDES_DIR . '/document/'. $template;

     return $path;
}
add_filter( 'document_template','my_template', 10, 2 );

I tried to change my return value as following, it doesn't work either:

return apply_filters( 'my_template', $path, $template);

I want to modify $path in the following filter. It has 1 input and 2 args.

function documents_template( $template = '' ) {
    
       $path = DOCUMENTS_INCLUDES_DIR . '/document/' . $template;

  return apply_filters( 'document_template', $path, $template );
}

This is my function to add filter, it gets error message, how to get it right?

function my_template( $template = '' ){

      $path = MY_INCLUDES_DIR . '/document/'. $template;

     return $path;
}
add_filter( 'document_template','my_template', 10, 2 );

I tried to change my return value as following, it doesn't work either:

return apply_filters( 'my_template', $path, $template);
deleted 1 characters in body
Source Link
Jenny
  • 1.8k
  • 4
  • 26
  • 41

I want to modify $path in the following filter. It has 2 args.

function documents_template( $template = '' ) {
    
       $path = DOCUMENTS_INCLUDES_DIR . '/document/' . $template;

  return apply_filters( 'document_template', $path, $template );
}

This is my function to add filter, it gets error message, how to get it right?

function my_template( $template = '' ){

      $path = MY_INCLUDES_DIR . '/document/'. $template;

     return $path;
}
add_filter( 'documents_template''document_template','my_template', 10, 2 );

I tried to change my return value as following, it doesn't work either:

return apply_filters( 'my_template', $path, $template);

I want to modify $path in the following filter. It has 2 args.

function documents_template( $template = '' ) {
    
       $path = DOCUMENTS_INCLUDES_DIR . '/document/' . $template;

  return apply_filters( 'document_template', $path, $template );
}

This is my function to add filter, it gets error message, how to get it right?

function my_template( $template = '' ){

      $path = MY_INCLUDES_DIR . '/document/'. $template;

     return $path;
}
add_filter( 'documents_template','my_template', 10, 2 );

I tried to change my return value as following, it doesn't work either:

return apply_filters( 'my_template', $path, $template);

I want to modify $path in the following filter. It has 2 args.

function documents_template( $template = '' ) {
    
       $path = DOCUMENTS_INCLUDES_DIR . '/document/' . $template;

  return apply_filters( 'document_template', $path, $template );
}

This is my function to add filter, it gets error message, how to get it right?

function my_template( $template = '' ){

      $path = MY_INCLUDES_DIR . '/document/'. $template;

     return $path;
}
add_filter( 'document_template','my_template', 10, 2 );

I tried to change my return value as following, it doesn't work either:

return apply_filters( 'my_template', $path, $template);
added 129 characters in body
Source Link
Jenny
  • 1.8k
  • 4
  • 26
  • 41
Loading
Source Link
Jenny
  • 1.8k
  • 4
  • 26
  • 41
Loading