Link to user’s profile settings page?
The user edit page of the current user is /wp-admin/profile.php, so you can just do admin_url( ‘profile.php’ ), which is the way it is used in the WP source code.
The user edit page of the current user is /wp-admin/profile.php, so you can just do admin_url( ‘profile.php’ ), which is the way it is used in the WP source code.
You can use get_stylesheet_directory() to refer to your child theme, then you can point to your file. require_once( get_stylesheet_directory() . ‘/includes/theme-styles.php’ ); It will load your file and replace the parent theme file.
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
the_permalink echos out the permalink of the current post to the frontend. get_permalink however returns it as a variable, but does not echo it out. You can also pass a post ID to it if you want the permalink of another post. the_permalink is equivalent to: echo get_permalink(); Which is very close to what it … Read more
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
The page ID (or object ID, since a menu item can link to any object) is stored in the postmeta table, with the key _menu_item_object_id. So you can get the page ID with the following code: get_post_meta( $item->ID, ‘_menu_item_object_id’, true );
In any foreach loop, the last value of the array being looped over remains after the end of the foreach loop. That is why one should actually always unset that value after the foreach loop is done. wp_list_pluck() is also just a basic foreach loop if $index_key is not passed. Also, as with any foreach … Read more
t f’s answer got me thinking. Actually, I can use the core function and adapt it as I like but just put everything in a new function. So here goes: function my_wp_is_mobile() { static $is_mobile; if ( isset($is_mobile) ) return $is_mobile; if ( empty($_SERVER[‘HTTP_USER_AGENT’]) ) { $is_mobile = false; } elseif ( strpos($_SERVER[‘HTTP_USER_AGENT’], ‘Android’) !== … Read more
The difference between theme and non-theme code is organizational rather than technical. Any code that is active contributes to resulting environment, does not matter where it is loaded from. There is number of places where code gets loaded from, which are not part of WordPress core: wp-config.php configuration file active theme (and its parent in … Read more
You cannot do that with pure PHP, because the fields are fetched from existing fields, and there is no hook. But you can use JavaScript, check if the post type supports custom fields and the field does not exist already – and insert it: <?php # -*- coding: utf-8 -*- /* Plugin Name: Extend custom … Read more