How to add/change a value of $wpdb property/var?

Yep, just declare global $wpdb early enough and modify its fields. Codex docs for add_metadata() say exactly that: Note that you will also have to register the table with the $wpdb object in order for it to work. Simply add the following to WordPress’ init hook (or at least before you attempt to use any … Read more

Setting a page link in the footer?

What may be easier (if you don’t necessarily want all the same menu items to appear in the footer) is to: Create a new menu, “Footer Menu” for example Add-in whatever links (pages) are needed there Add a widget (called Custom Menu) to a footer widget position (if your current theme supports it). Let me … Read more

Deep linking to an accordion tab with Visual Composer

After having the same issue, I’ve come up with a basic solution – hopefully it’s not too late for you. The Visual Composer “accordion plugin” seems to be a wrapper around the jQuery UI accordion; so the same methods are available. I’ve written some basic (room for improvement no doubt) code that checks if there … Read more

Open link in a new tab checked by default when adding a new link in visual post editor

Add this function in your theme’s functions.php function my_enqueue($hook) { if (‘post.php’ != $hook ) { return; } wp_enqueue_script(‘my_custom_script’, get_template_directory_uri() . ‘/js/myscript.js’); } add_action(‘admin_enqueue_scripts’, ‘my_enqueue’);` In myscript.js place this code jQuery(document).ready(function(){ jQuery(‘#wp-link-target’).prop(“checked”, true); }) It worked for me.

programatically change href to onclick=window.open

Parsing HTML with regular expressions is not ideal. A better alternative is to use DOMDocument and DOMXpath; This code uses DOMDocument and DOMXpath to parse and modify the HTML without relying on regular expressions. Each link in the content will have the onclick attribute added along with the appropriate window.open() code using the URL pulled … Read more

Link Category Description

OK, with the help of a friend I was able to get this done. I ditched the wp_list_bookmarks and went with a combination of get_terms and get_bookmarks. function blogroll_page( $args = array() ) { if(is_page(‘blogroll’)) { if( $terms = get_terms( ‘link_category’, $args = array(‘exclude’ => 16) ) ) { foreach( $terms as $c ) { … Read more

Retrieving all Links from a Post?

I’ll answer your question below, but have you looked at using embeds? Look here for more information: http://codex.wordpress.org/Embeds The simplest regex for this would look something like http\:\/\/.*\b Here’s an example of it in action: <?php $file=”test.txt”; $fp = fopen($file, ‘r’); $contents = fread($fp, filesize($file)); $matches = array(); preg_match_all(‘/http\:\/\/.*\b/’, $contents, $matches); print_r($matches); ?> Where the … Read more