Create highly customized submenu (possibly using wp_list_pages)

After days of working on this, I was able to loop through the results of wp_list_pages to customize the menu the way I needed. <?php if(count(get_post_ancestors($post->ID)) == 1 ) { echo ‘<ul>’; $args = array( ‘post_type’ => ‘page’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘post_parent’ => $post->post_parent, ); $query = new WP_Query($args); while ($query->have_posts()) { … Read more

WordPress converts media extention URL automatically to video player

You should consider using the Auto-embeds Disabler plugin here: https://gist.github.com/ocean90/3796628 Note that it’s actually just a single line of code, if you prefer to add that to your functions.php – but I’d suggest keeping it as a plugin so you can easily activate/deactivate that functionality. remove_filter( ‘the_content’, array( $GLOBALS[‘wp_embed’], ‘autoembed’ ), 8 ); Note that … Read more

Overwriting the menu break points of twentysixteen in child theme

Copy the js folder of the parent TwentySixteen theme to child theme root. Then add the below code in your functions.php– function the_dramatist_dequeue_scripts() { wp_dequeue_script( ‘twentysixteen-script’ ); wp_deregister_script( ‘twentysixteen-script’ ); } add_action( ‘wp_print_scripts’, ‘the_dramatist_dequeue_scripts’ ); function the_dramatist_twentysixteen_scripts() { wp_enqueue_script( ‘twentysixteen-child-script’, get_stylesheet_directory_uri() . ‘/js/functions.js’, array( ‘jquery’ ), null, true ); } add_action( ‘wp_enqueue_scripts’, ‘the_dramatist_twentysixteen_scripts’ ); Then … Read more

Limit 1 global comment per minute

Place the following into a custom plugin or into your child theme’s functions file: add_action(“wp_insert_comment”, function() { global $current_user; if ( !$current_user->ID ) return; update_user_meta( $current_user->ID, “se_last_commented”, time() ); }); add_action(“init”, function() { if ( “wp-comments-post.php” == $GLOBALS[‘pagenow’] ) { global $current_user; if ( !$current_user->ID ) return; $last_commented = (int) get_user_meta( $current_user->ID, “se_last_commented”, 1 ); … Read more

Adding an external HTML link to a post thumbnail

It sounds like you are trying to use get_permalink() on a URL. get_permalink() expects a post ID, not a URL. Try this: add_filter( ‘post_thumbnail_html’, ‘my_post_link_html’, 10, 3 ); function my_post_link_html( $html, $post_id, $post_image_id ) { // Uncomment for debugging. This will replace the featured image with the debugging output. // exit ( var_dump( $GLOBALS[‘ghostpool_affiliate_button_link’] ) … Read more