Enable identical menu on network sites

Worked it out. Assuming using a theme which has a menu location called ‘primary’, and you have just created a menu with an id contained in $menu_id $menu_locations = get_nav_menu_locations(); $new_menu_locations = array_map( ‘absint’, [‘primary’ => $menu_id]); $menu_locations = array_merge( $menu_locations, $new_menu_locations ); set_theme_mod( ‘nav_menu_locations’, $menu_locations ); This is pretty much exactly how WordPress itself … Read more

Fetching WP.me shortlinks for posts using WP Rest API

This has been resolved by registering a new field in the rest api using the following functions. add_action( ‘rest_api_init’, ‘sam_add_custom_rest_fields’ ); function sam_add_custom_rest_fields() { $sam_short_link_schema = array( ‘description’ => ‘Short Link’, ‘type’ => ‘string’, ‘context’ => array( ‘view’ ) ); register_rest_field( ‘post’, ‘samad_short_link’, array( ‘get_callback’ => ‘sam_get_short_link’, ‘update_callback’ => null, ‘schema’ => $sam_short_link_schema ) ); … Read more

Paid membership Pro Rest API

First you will need to have the plugin installed (paidmembershipspro ) otherwise you wont be able to call the function “pmpro_getMembershipLevelForUser” and then you just need to copy the code below to your functions.php file which is inside your WordPress theme. /* Call to http://yoursite.com/[email protected]&secret=CHECK to check the membership level of a user. */ function … Read more

How Can I keep password protected posts in the json requests but not on frontend queries?

I sort of solved this by using this: function ar6_password_post_filter( $where=”” ) { if (!is_single() && !current_user_can(‘edit_private_posts’) && !is_admin()) { $where .= ” AND post_password = ””; } return $where; } add_filter( ‘posts_where’, ‘ar6_password_post_filter’ ); This allows user roles of administrator and editor to still see the password protected posts on the front end of … Read more