Change the_title() of a page dynamically

I would use the is_page_template() conditional: if ( is_page_template( ‘page-courses.php’ ) ) { // The current page uses your // custom page template; // do something } Edit You would use this conditional inside your filter callback: function wpse83525_filter_the_title( $title ) { if ( is_page_template( ‘page-courses.php’ ) ) { return ‘Custom Title’; } return $title; … Read more

How to Remove Certain Screen Options and Meta Boxes from add/edit post type?

What you need is in global $wp_meta_boxes indexed by get_current_screen()->id. Removing the screen options will also remove the metaboxes which you can do just before screen options are displayed using the ‘in_admin_header’ hook. So let’s assume you want to get rid of the “Send Trackbacks” screen option which you see in this screenshot: Drop the … Read more

How to output message during plugin activation

For testing purposes you can use the log system (php_error.log): error_log(‘Plugin activated’, 0); // Check for DB table existance if(!$this->hasDBTable()){ error_log(‘Database not present’, 0); if($this->createCELabelsDBTables()){ error_log(‘Database was created.’, 0); } else { error_log(‘Error creating the CE Labels Plugin db tables!’, 0); } } else { error_log(‘Database OK’, 0); } To output error to the user … Read more

Checking if a file is already in the Media Library

global $wpdb; $image_src = wp_upload_dir()[‘baseurl’] . “https://wordpress.stackexchange.com/” . _wp_relative_upload_path( $filename ); $query = “SELECT COUNT(*) FROM {$wpdb->posts} WHERE guid=’$image_src'”; $count = intval($wpdb->get_var($query)); You can use this at the top of your code. Then check the value of $count. If it’s 0, then you can continue adding the attachment

How can I load a page template from a plugin?

You can use the theme_page_templates filter to add templates to the dropdown list of page templates like this: function wpse255804_add_page_template ($templates) { $templates[‘my-custom-template.php’] = ‘My Template’; return $templates; } add_filter (‘theme_page_templates’, ‘wpse255804_add_page_template’); Now WP will be searching for my-custom-template.php in the theme directory, so you will have to redirect that to your plugin directory by … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)