How to generate/update a XML sitemap without plugins?

The following code works right off the bat. Your sitemap will show up on: https://your-website-name.com/sitemap.xml Every time you create or update a page, post or custom post type it will show. Make sure to add the name of your custom post type: add_action( ‘publish_post’, ‘ow_create_sitemap’ ); add_action( ‘publish_page’, ‘ow_create_sitemap’ ); add_action( ‘save_post’, ‘ow_create_sitemap’ ); function … Read more

Does wordpress have a post hit counter?

Not in core. You can use post meta to store this information on page loads. If you have caching plugins enabled, you might want to increment the hit counter with an AJAX call, otherwise you can just add this directly in your single.php and page.php templates: //Add to functions.php function get_hits(){ global $post; $hits = … Read more

Add Rewrite Rule for custom page

function add_my_rule() { global $wp; $wp->add_query_var(‘args’); $wp->add_query_var(‘arg_username’); add_rewrite_rule(‘writer/([0-9]+)/([^/]*)/page/([0-9]+)’,’index.php?pagename=writer&args=$matches[1]&arg_username=$matches[2]&paged=$matches[3]’,’top’); add_rewrite_rule(‘writer/([0-9]+)/([^/]*)’,’index.php?pagename=writer&args=$matches[1]&arg_username=$matches[2]’,’top’); /*global $wp_rewrite; $wp_rewrite->flush_rules();*/ } add_action(‘init’, ‘add_my_rule’); This should do the trick. One rewriterule for writer/user_id/username (username isn’t used in the rewriterule but is necessarily to make it work. The second rewriterule is the same except that it adds pagination. EDIT: added arg_username in code above.

Facebook comments box on front page

Fast ‘n’ Hacky The problem can be solved by changing line 319 in facebook.php to the following: if (is_home()) { This way, the front page is not treated as a home page but as a regular page, for which the facebook feature settings can be applied (and will be handled correctly). More Elegant/Complex Here is … Read more

Fatal error: Call to undefined function wp_get_current_user()

wp_get_current_user() is a pluggable function and not yet available when your plugin is included. You have to wait for the action plugins_loaded: Example: add_action( ‘plugins_loaded’, ‘wpse_92517_init’ ); function wpse_92517_init() { if(!is_super_admin()) add_action(‘widgets_init’,’my_unregister_widget’); } function my_unregister_widgets() { unregister_widget( ‘WP_Widget_Pages’ ); unregister_widget( ‘WP_Widget_Calendar’ ); } Or move the check into the widget function: add_action( ‘widgets_init’, ‘my_unregister_widget’ ); … Read more

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