How to override filter in child theme?

I do not see you actually calling child_remove_parent_function() in your code. Another issue to be aware of is timing. It is counter–intuitive, but functions.php files are loaded in order of child first, parent second. Overall you need to ensure two things: code works at all it is called at the appropriate moment, after parent theme … Read more

Simple/basic use of get_current_screen

I haven’t tested this but theoretically you could do something like this (Using the Codex as an Example): function load_custom_wp_admin_style() { $pageArr = array(1, 2, 3); if(isset($_GET[‘post’]) && in_array($_GET[‘post’], $pageArr)){ wp_register_style( ‘custom_wp_admin_css’, get_template_directory_uri() . ‘/admin-style.css’, false, ‘1.0.0’ ); wp_enqueue_style( ‘custom_wp_admin_css’ ); } } add_action( ‘admin_enqueue_scripts’, ‘load_custom_wp_admin_style’ ); We get the current screen and set the … Read more

Functions.php: If its single?

add_filter(‘wpseo_set_title’, ‘wpseo_set_title_callback’); function wpseo_set_title_callback($input) { if (is_single()) { return ‘Now Single’; } // return default return $input; } Or example from wpSEO Hilfecenter: add_action(‘init’, ‘wpseo_set_title’); function wpseo_set_title() { add_filter( ‘wpseo_set_title’, ‘wpseo_set_title_callback’ ); } function wpseo_set_title_callback($input) { if (is_single()) { return ‘Now Single’; } // Else return default: return ‘Das Buch “‘. $input . ‘” probelesen.’; … Read more

Override a class function to include a custom template

Try something like the code below: function wpse282960_remove_filter() { $run_import_some_events = run_import_some_events(); remove_filter( ‘the_content’, array($run_import_some_events->cpt, ‘some_events_meta_before_content’) ); } add_action( ‘template_redirect’, ‘wpse282960_remove_filter’ );

WordPress – thumbnail image from youtube (function and loop)

Well, assuming the post content will be provided by Youtube embedded code, a change in the regular expression is needed. The function must obtain the source of the iframe. So would be as follows: function get_thumbnail_fromyoutube( $size = 0 ) { global $post, $posts; $youtube=””; $get_url = preg_match_all(‘/src=”https://wordpress.stackexchange.com/questions/151570/([^”]+)”https://wordpress.stackexchange.com/”, $post->post_content, $matches); $youtube = $matches[1][0]; var_dump($youtube); if(preg_match(‘/^(http:\/\/www.youtube.com)/’, … Read more

wp_delete_attachment

Try the following: Replace your current upload filter with the one below Create a new custom post and upload some files Check the files have been moved to the correct uploads folder Delete the custom post and then check the files have been deleted New uploads filter function: function set_upload_dir( $args ) { if ( … Read more

display public excerpt for private post

I’ve not tested this, but you should be able to complete this task by placing the following code in your template above the loop. query_posts( array( ‘post_status’ => array( ‘published’, ‘private’ ) ) ); This should allow for published and private posts to be displayed in that template.