Unable to insert current username into custom table through html form

wp_get_current_user returns a WP_User object. You’ll need to pull the name out of that in order to send it try $current_user->display_name in your insert statement. On that note, you should absolutely not be inserting unsanitized user entered data into your database. Please look into SQL injection and input sanitization.

adding or removing endforeach; throws error!

If you pasted your code directly, The second curly bracket here <?php if($k==0) { ?> active <?php { ?> should be a closing one, like this: <?php if($k==0) { ?> active <?php } ?> There is also a stray slash </a>/</li> – should be – </a></li> – but that shouldn’t cause any PHP errors.

Error inserting into custom table – Object of class wpdb could not be converted to string [closed]

$wpdb->$table_name is not a valid table name. Use $table_name $wpdb->query( $wpdb->prepare( ” INSERT INTO $wpdb->$table_name ( first_name, last_name, email,telephone,user_name) VALUES ( %s, %s, %s,%s,%s ) “, $first_name,$last_name,$email,$telephone,$current_username ) ); should be $wpdb->query( $wpdb->prepare( ” INSERT INTO $table_name ( first_name, last_name, email,telephone,user_name) VALUES ( %s, %s, %s,%s,%s ) “, $first_name,$last_name,$email,$telephone,$current_username ) );

URL rewrite rule

function custom_rewrite_rules() { add_rewrite_rule( ‘^product_brand/([^/]+)/page/([0-9]{1,})/?’, ‘index.php?product_brand=$matches[1]&page=$matches[2]’, ‘top’ ); add_rewrite_rule( ‘^product_brand/([^/]+)/([^/]+)/page/([0-9]{1,})/?’, ‘index.php?product_brand=$matches[1]&product_cat=$matches[2]&page=$matches[3]’, ‘top’ ); add_rewrite_rule(‘^product_brand/([^/]+)/([^/]+)?’, ‘index.php?product_brand=$matches[1]&product_cat=$matches[2]’, ‘top’); add_filter( ‘query_vars’, function( $vars ){ $vars[] = ‘product_brand’; $vars[] = ‘product_cat’; return $vars; } ); } add_action(‘init’, ‘custom_rewrite_rules’); and pagination add_action( ‘pre_get_posts’, function() { $page = get_query_var(‘page’); $query->set( ‘paged’, $page ); return $query; } );

Trying to publish a little bit of Javascript on the homepage AND at the bottom

You can use the functions is_front_page() or is_home() depending on what your home page is. Also instead of wp_head you can use wp_enqueue_scripts Your code will look something like this function add_inline_script() { if(is_home() || is_front_page) wp_enqueue_script(‘js-handler-name’, ‘js-url’); } add_action( ‘wp_enqueue_scripts’, ‘add_inline_script’);

How to apply ‘add two more posts’ to media content?

First, modify your example by specifying post type post and removing the cat and post__not_in arguments. Next, if you want to make sure you’re looking at the parent’s date and not the media’s date, you’ll also need to make sure to have a fallback in case someone tries to view an image that isn’t attached … Read more