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’ );

Add Top-Level Menu that opens URL

I’ve experimented with various solutions or workarounds proposed elsewhere on this site – for instance here: Adding an Arbitrary Link to the Admin Menu? and this one here: http://www.techedg.com/2014/09/06/5575/a-simple-way-to-add-an-external-link-to-the-wordpress-admin-menu/ All of the solutions that I tested that worked included that behavior of adding an unwanted blank admin page. I’m not sure that there is not … Read more

Why does “get_option” pull in the older value in options.php, rather than the newer value, on submission of a form?

If your update_option call runs after you assign $posts1 and $posts2, then of course they’ll hold the “old” value, even if you sleep for eternity 😉 Either run the update earlier, or (re)assign the variables afterwards. $posts1 = get_option( ‘post1’ ); echo get_option( ‘post1’ ); // [my_id] echo $posts1; // [my_id] update_option( ‘post1’, ‘foobar’ ); … Read more

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.

Setting up the child theme so as to enable right-to-left WordPress?

You also need to include the RTL.css file which is in the theme too: add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ ); function my_theme_enqueue_styles() { wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ ); wp_enqueue_style( ‘rtl-style’, get_template_directory_uri() . ‘/rtl.css’ ); } To use the rtl.css from your theme directory change the code to: add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ ); function my_theme_enqueue_styles() { wp_enqueue_style( ‘parent-style’, … Read more