How do you log a user out with wp_logout?

If you’re using wp_logout in your own code, its probably best to exit or wp_redirect immediately afterwards. You can call wp_set_current_user(0) after wp_logout() to manually log the user out instantly, if you need to continue executing PHP but don’t want the user to be logged in.

How to load a jQuery script last?

add_action(‘wp_footer’,’myscript_in_footer’); function myscript_in_footer(){ ?> <script type=”text/javascript”> jQuery(document).ready(function(){ jQuery(“div.domTip_tipBody”).mouseover(function(){ jQuery(“#yyy a.tippy_link”).css(“background-color”,”yellow”);}); jQuery(“div.domTip_tipBody”).mouseout(function(){ jQuery(“#yyy a.tippy_link”).css(“background-color”,”red”); }); }); </script> <?php }

Getting redirect to happen before header output

Your method is called too late. I don’t know how you call this method but you need to run it before output is sent to the browser– usually that means before get_header(). There are a number of hooks that can be used. For example (from https://wordpress.stackexchange.com/a/131210/21376): add_action( ‘template_redirect’, function() { if (is_single()) { wp_safe_redirect(home_url()); exit; … Read more

Sharing Header Components Across Multisite

Outsource this function into a Plugin If you want a specific function available across multiple themes, it is best to have it in a Plugin, and activate it networkwide. Find the function Locate the function in the theme where it is available. You now have two possibilities: Delete the function from the current theme Make … Read more

Remove rel=shortlink from HTTP header

<?php add_filter(‘after_setup_theme’, ‘remove_redundant_shortlink’); function remove_redundant_shortlink() { // remove HTML meta tag // <link rel=”shortlink” href=”http://example.com/?p=25″ /> remove_action(‘wp_head’, ‘wp_shortlink_wp_head’, 10); // remove HTTP header // Link: <https://example.com/?p=25>; rel=shortlink remove_action( ‘template_redirect’, ‘wp_shortlink_header’, 11); } Tested in WordPress 4.4 and up to 4.9.1

URL Redirect and Bulk Actions in wp_list_table

Understand hierarchy, You don’t need to redirect as form are posting values on same page. function process_bulk_action() { // Some security check code here // Get the bulk action $action = $this->current_action(); if ($action == ‘bulk_trash’) { // Code for the “delete process” $delete_ids = esc_sql($_POST[‘bulk-delete’]); //loop over the array of record ids foreach($delete_ids as … Read more

Image slider to display at the very top of home page

Note: The slider only displays if you install the plugin and use the correct slider I.D in the code for the template tag after creating a slider and adding images. The screenshot i posted below proves my code works. Here’s the header.php code with the template tag for the slider on line 36 <?php /** … Read more

How to place an image into header.php? [closed]

Don’t use a relative URL. If you look at the source you are probably trying to load the image from http://sitename.com/images/ when what you likely want is http://sitename.com/wp-content/themes/themename/images/. Assuming the image is in the theme directory in a folder that shares a directory with style.css, do this: <img id=”topL” src=”https://wordpress.stackexchange.com/questions/78271/<?php echo get_stylesheet_directory_uri(); ?>/images/img01.png”/> http://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri

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