Disabling user capability to edit_posts or delete_posts in the front-end

By using this functionality we can able to remove the delete option of the page or post. function wp_restrict_page_deletion( $caps, $cap, $user_id, $args ) { $post_id = $args[0]; if ( $cap === ‘delete_post’ && $post_id === your post id* ) { $caps[] = ‘do_not_allow’; } return $caps; } add_filter( ‘map_meta_cap’, ‘wp_restrict_page_deletion’, 10, 4 ); I … Read more

Admin Bar – Customizer Label Change

You can use the get_node function and admin_bar_menu action. Like so, function edit_customizer_node( $wp_admin_bar ) { $customize = $wp_admin_bar->get_node( ‘customize’ ); if ( $customize ) { $customize->title = __( ‘Customize Theme’, ‘text-domain’ ); $wp_admin_bar->remove_node( ‘customize’ ); $wp_admin_bar->add_node( $customize ); } } add_action( ‘admin_bar_menu’, ‘edit_customizer_node’, 999 ); This can be placed in your theme’s functions.php file. … Read more

How to update the children of a post?

get_children returns an array of post objects by default: https://developer.wordpress.org/reference/functions/get_children/ So you would have to use ‘ID’ => $child->ID, in this case… also my want to wrap the foreach with if (count($children) > 0) {} to prevent possible errors where there are no children. ie: $children = get_children( $mainid ); if (count($children) > 0) { … Read more

How to fix blog article view and share #’s?

The Newspaper theme uses ajax to display views and pull in social data. https://forum.tagdiv.com/ajax-view-count/ In order to keep requests to admin-ajax.php to a minimum, you should reduce the number of different blocks used on your site as well as reduce the ajax filters and pagination for each block. This will reduce server requests considerably. Please … Read more

Looking to create an “update theme” functionality for a custom front-end dashboard

You could add a REST endpoint to check if the current theme has an update. Here’s a quick example to get you started: function wpd_register_themecheck_route(){ register_rest_route( ‘themecheck/v1’, ‘/updates/’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘wpd_check_theme’ ) ); } add_action( ‘rest_api_init’, ‘wpd_register_themecheck_route’ ); function wpd_check_theme(){ $current_theme = get_option( ‘template’ ); $theme_updates = get_option( ‘_site_transient_update_themes’ ); $return … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)