What’s the difference between WordPress random_int() and PHP built-in function random_int()?

WordPress is old. In fact, it is older than PHP7, in which PHP introduced random_int(). WP wanted/needed this functionality before, so another method was implemented. how does the PHP interpreter understand which of the two functions I’m calling? Good question. The interpreter doesn’t understand this. And hence, if you had PHP7 and would define this … Read more

Add container to nav_menu sub menu

Use a custom walker, extend the methods start_lvl() and end_lvl. Sample code, not tested: class WPSE_78121_Sublevel_Walker extends Walker_Nav_Menu { function start_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat(“\t”, $depth); $output .= “\n$indent<div class=”sub-menu-wrap”><ul class=”sub-menu”>\n”; } function end_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat(“\t”, $depth); … Read more

How to Add Image to WordPress RSS-Feed with no Plug-in?

Here is a great example. How to display featured post thumbnails in WordPress feeds paste this code snippet in your theme functions.php file // display featured post thumbnails in WordPress feeds function wcs_post_thumbnails_in_feeds( $content ) { global $post; if( has_post_thumbnail( $post->ID ) ) { $content=”<p>” . get_the_post_thumbnail( $post->ID ) . ‘</p>’ . $content; } return … Read more