How to create custom home page via plugin?

An Active Plugin To make an active plugin, use the following resources: WordPress Codex: Writing a Plugin WordPress Essentials: How To Create A WordPress Plugin by Daniel Pataki From the following StackExchange thread, try to understand what are the Hooks and what are things acting behind a plugin: How to edit a wordpress plugin without … Read more

Prevent multiple counts by same user – WP PostViews plugin

Since the plugin author does not offer any actions or filters for us to hook onto, we’ll have to settle for “listening” to changes to the views meta field instead. function wpse_104324_prevent_multiple_views( $meta_id, $object_id, $meta_key, $meta_value ) { if ( $meta_key === ‘views’ ) { if ( ! empty( $_COOKIE[ USER_COOKIE . ‘_views’ ] ) … Read more

Can I add pages to my custom menu via script?

You can use wp_nav_menu_{$menu->slug}_items hook and add you link with a callback function, for example if your menu slug is header-menu then something like this: add_filter(‘wp_nav_menu_header-menu_items’, ‘add_my_extra_links’,10,2); function add_my_extra_links($items, $args) { $newitems=”<li><a title=”Test Link” href=”http://google.com”>Google</a></li>”; $newitems .= ‘<li><a title=”Test Link” href=”http://yahoo.com”>Yahoo</a></li>’; $newitems .= ‘<li><a title=”Test Link” href=”http://bing.com”>Bing</a></li>’; $newitems .= $items; return $newitems; } Update I … Read more

Current class on admin menu using add_submenu_page()

Try this: add_menu_page(__(‘My Plugin’, ‘myplugin’),__(‘My Plugin’, ‘myplugin’), ‘edit_posts’,’my-plugin-dashboard’,’my_plugin_dashboard’,’icon’); // dashboard submenu – this fails to highlight with current add_submenu_page(‘my-plugin-dashboard’, __(‘Dashboard’,’myplugin’), __(‘Dashboard’,’myplugin’), ‘edit_posts’, ‘my-plugin-dashboard’, ‘my_plugin_dashboard’ ); // settings submenu – this fails to highlight with current add_submenu_page(‘my-plugin-dashboard’, __(‘Settings’,’myplugin’), __(‘Settings’,’myplugin’), ‘manage_options’, ‘my-plugin-settings’, ‘my_plugin_settings’ ); Essentially: don’t use full page links with admin.php?… as the page slug. Especially … Read more