Toggle User Roles with button

As it happens, I have something very similar on one of my sites to to allow Administrators update some custom user meta. Basically, you need to add an additional column and then populate it with a link to do what you want. When you click the link some jQuery fires of an AJAX request to … Read more

How to Display a Plugin function (content) on frontpage using index.php

Your plugin inserts its feelbox widget by filtering the_content: if ($options[‘showinpostsondefault’] == ‘on’) { add_filter(‘the_content’, ‘add_feelbox_widget_to_posts’); } But your index page doesn’t display the_content, just Title, featured thumbnail, an excerpt and, number of comments. The plugin code you’ve shown us doesn’t include a print_feelbox_widget() function. Does such a function actually exist in your plugin? (Also, … Read more

WSoD being caused by this piece of code

You have a problem with your code formatting and syntax at the very least: function ref_access(){ global $error; if (is_user_logged_in()) // <– problem here… $newdb = new wpdb( ‘user’, ‘pass’, ‘db’, ‘localhost’ ); global $newdb; $hf_username = wp_get_current_user(); $inputValue = $_POST[$quanid]; $wpdb->insert( $table, array( ‘ItemID’ => $quanid ‘Price’ => $inputValue ‘user’ => $hf_username ), ); … Read more

Understanding and altering the structure of posted images

Lets start with your first code. If you add texts, captions etc. a shortcode will be generated: The function img_caption_shortcode() in wp-content/media.php is responsible to execute the shortcode. But this shortcode is only produced, when you use captions. Otherwise, it will be simply inserted the <a>– and <img>-Tag. who decides, what gets inserted? There is … Read more

Conditional read more adjustment

It was simpler than I thought. This has solved it. <?php add_filter(‘the_content_more_link’, ‘modify_read_more_link’); function modify_read_more_link() { return ‘<a class=”more-link” href=”‘ . get_permalink() . ‘”>Your Read More Link Text</a>’; } the_content(“Read More”); ?>

is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript

you can just check for the customize object, but if you absolutely need a conditional statement to determine whatever it is you need, you can do something like this: jQuery( function( $ ) { // set var var in_customizer = false; // check for wp.customize return boolean if ( typeof wp !== ‘undefined’ ) { … Read more