Adding a slide toggle on WordPress

WordPress has default jQuery. So, no need to load this file explicitly. JS Code: jQuery(‘#toggle-onoff-network’).on({ ‘click’: function () { var origsrc = jQuery(this).attr(‘src’); var src=””; if (origsrc == “https://wordpress.stackexchange.com/questions/166823/img1_on.png”) src=”img2_on.png”; if (origsrc == ‘img2_on.png’) src=”https://wordpress.stackexchange.com/questions/166823/img1_on.png”; jQuery(this).attr(‘src’, src); } }); // The script jQuery( “#netywork-toggle” ).click(function() { jQuery( “#share-stuff” ).slideToggle( “slow”, function() { // Animation complete. … Read more

How to use custom previous/next link ?

Do this to output only links for previous and next pages: <?php previous_posts_link ( ‘Previous’ ) ?> <?php next_posts_link ( ‘Next’ ); ?> Then add filters to your functions.php to add a class to each link: function next_posts_link_css ( $content ) { return ‘class=”next”‘; } add_filter( ‘next_posts_link_attributes’, ‘next_posts_link_css’ ); function previous_posts_link_css ( $content ) { … Read more

Strange iframes added in wordpress 4.1 localhost

This is not a WordPress issue. A Google search for boostsaves.com reveals it is a browser add-on that injects iframes into the page source of whatever you’re viewing. Use Google to find instructions on how to remove it from whatever browser you’re using.

Add shortcode in my div

You need the do_shortcode() function <?php echo do_shortcode(“[contact-form-7 id=”54″ title=”Contact form 1″]”); ?> I have not tested your shortcode.

Remove tags from wordpress head

I believe a filter on the_generator will do it. add_filter(  ‘the_generator’,  ‘__return_empty_string’, PHP_INT_MAX ); Reference: https://codex.wordpress.org/Function_Reference/_return_empty_string. https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/general-template.php#L2956

Is it safe to use WordPress generated classes?

Post ID Specific Classes are not reliable at all. The ID is based on when the page was created ( in what order since IDs auto-increment ). If the user “accidently” permanently deletes the page and needs to recreate it the page will have a new ID and thus not use any of the predefined … Read more

Allow HTML in Settings API input field

When you register a setting, you pass the santize callback for that setting: register_setting( ‘my_setting_group’, ‘my_setting_name’, // The next parameter is the validation callback ‘my_setting_validation’ ); Then, in the validation callback you can allow whatever you want. For example, in the next code snippet, users with unfiltered_html capability will be allowed to insert raw HTML … Read more

Add data-id attribute to child page links

Assuming that your html is outputted by a wordpress menu sitting in a sidebar, you have to extend the Walker_Nav_Menu Class which is used by menu template functions like wp_nav_menu. As stated in the reference of wp_nav_menu, you could modify its output like: class My_DataId_Walker_Nav_Menu extends Walker_Nav_Menu { // other code found in original Walker_Nav_Menu … Read more

Add the title attribute to links

Turns out you are not the only one: https://core.trac.wordpress.org/ticket/32095 It looks like this was removed in a recent update (4.2) and I can see why they did it. User interface can be confusing at times. You can read more about the removal here: http://wptavern.com/how-to-restore-the-link-title-attribute-removed-in-wordpress-4-2 There is a WordPress plugin, however, that seems to add it … Read more