I don’t understand how this parameter works..?

Let’s see if we can break it down so it’s easy to understand. You have a PHP function named ‘cm_title’: function cm_title($text) { return ‘TESTING  ’ . $text; } It only does 1 thing. It takes what it is given, ‘$text’, and returns that $text with the words ‘Testing ‘ prepended to it. How does … Read more

Accessing GET variable named ‘error’

Your problem is that you’re using Reserved Terms. error is a reserved term, you can’t use it. To get around this, you could intercept the request early, and do a redirect, changing the query parameters in the process. For example, handling a link get parameter: add_action( ‘wp’ , ‘reserved_term_intercept’ ); function reserved_term_intercept(){ global $wp_query; if( … Read more

Delete Associated Media Upon Page / Post Deletion

Just for clarity: borrowing from this answer, add the following to your theme’s functions.php: function wpse_188427_delete_post_media( $post_id ) { $attachments = get_posts( array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => -1, ‘post_status’ => ‘any’, ‘post_parent’ => $post_id, ) ); foreach ( $attachments as $attachment ) { wp_delete_attachment( $attachment->ID ); } } add_action( ‘before_delete_post’, ‘wpse_188427_delete_post_media’ ); // Uncomment … Read more

How to get variables from fucntion.php to my plugin files

There is three way to use function.php file variable into plugin file. Using global. Make sure you globalize it first. global $my_variable; echo $my_variable; I recommend is using WordPress built-in filter mechanism add_filter. You add the filter in your functions.php file and apply it where needed. In functions.php: add_filter( ‘my_variable’, ‘return_my_variable’ ); function return_my_variable( $arg … Read more