add query string to all pages after user logged in

add following code to functions.php, add_action(‘wp_head’, ‘your_function’); function your_function(){ if ( is_user_logged_in() ) { $genre_url = add_query_arg(‘aff’, ‘1234567’, get_permalink()); } } Hope this will help you. for more information, is_user_logged_in() How can I include a query string with get_permalink wp_head action hook get_permalink()

Should I use `get_stylesheet_uri()` or `get_template_directory_uri()` when calling my CSS Stylesheet?

WordPress recommends the proper way to enqueue the main style is the method-A. Please see the WordPress theme development handbook here (though both methods will work). https://developer.wordpress.org/themes/basics/including-css-javascript/ It’s not clear to me why you want to link the two .css file? You can create custom .css file and enqueue it using method-B. However, if you … Read more

Cross origin ajax request always returns 0 when calling get_current_user_id();

Don’t write your own bootstrapper, use Ajax hooks via wp-admin/admin-ajax.php Documentation: https://codex.wordpress.org/AJAX_in_Plugins Then you can be sure WordPress has included all the functions you need. Update: I missed the bit about posting from local machine to remote server. If your JavaScript is running on another domain, it won’t be sending back your web server’s login … Read more

Adding Gravity Form With if(is_page) Is Not Working

if you got following in your functions.php function add_split_test_forms() { if (is_page(‘Homepage’)): gravity_form(19, false, false, false, ”, false); endif; } you will at least need to run this function once: add a line add_split_test_forms() in your functions.php. if your condition if (is_page(‘Homepage’)): is correct. (I prefer if ( is_front_page()): should also work.) Then your form … Read more

static array on functions.php

This is a good use case for the Object Cache: WP_Object_Cache is WordPress’ class for caching data which may be computationally expensive to regenerate, such as the result of complex database queries. You can store things in the cache with wp_cache_set() and retrieve them with wp_cache_get(). You just need to give it a key and … Read more

Add HTML before a specific div?

Seems like jQuery is best for this case. Mainly answering for myself in case I’ll need it again in the future: <head> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js”></script> <script> $(document).ready(function(){ $(“#this_comes_before”).insertBefore(“#wc_checkout_add_ons”); }); </script> </head> <body> <div id=”wc_checkout_add_ons”>stuff</div> <div id=”this_comes_before”>something</div> </body> Edit for future me: Use this instead you lazy asshole… add_action( ‘woocommerce_checkout_after_customer_details’, ‘test99’ ); function test99() { echo “your … Read more

Two ‘If Statements’ is my syntax correct (functions.php) and what is ‘false’

You should use elseif for the second if statement: $title1 = single_term_title( ‘Conferences In&nbsp;’, false ); $title2 = single_term_title( ‘CConferences In&nbsp;’, false ); add_filter( ‘get_the_archive_title’, ‘my_theme_archive_title’ ); function my_theme_archive_title( $title ) { if ( is_tax(‘us_state’) ) { $title1; } elseif ( is_tax(‘country’) ) { $title2; } else { return $title; } } You can read … Read more