Inserting ads within content

Have faith 😉 Unfortunately, your code ain’t correct in multiple ways. It assumes that the content only consists of content enclosed by paragraphs and doesn’t work correctly if not. This would be one solution: add_filter(‘the_content’, ‘prefix_insert_post_ads’); /** * Content Filter */ function prefix_insert_post_ads($content) { $insertion = ‘Your AD Code’; if (is_single() && ! is_admin()) { … Read more

Updata Metadata WP Rest API

Two things need to be changed 1 – wishlistPost.metadata.wishlist_array which is the metadata returns an object with a string inside, not an array. var wishlist_array = wishlistPost.metadata.wishlist_array[0]; //Get current string wishlist_array += postID + “,”; //Concat new ID to the current string 2 – JSON.stringify(wishlist_array) is not needed as stated above wishlist_array is a string … Read more

How to pre-fill Google Forms URLs with logged-in WordPress user’s data

AS easy as you said: $user = wp_get_current_user(); if(!empty($user)) { $email = $user->user_email; $fname = $user->user_firstname; $sname = $user->user_lastname; $url=”https://docs.google.com/forms/d/e/1FAIpQLSeChqhovV70FbILIlfeo8K5UL9q3hfjPkngEe4IJkXMmCbawg/viewform?entry.646601418=STUDENT+01&entry.280532864=”.$email.’&entry.1176284616=’.$fname.’&entry.165661554=’.$sname; echo $url; } else { $email=”[email protected]”; $url=”https://docs.google.com/forms/d/e/1FAIpQLSeChqhovV70FbILIlfeo8K5UL9q3hfjPkngEe4IJkXMmCbawg/viewform?entry.646601418=STUDENT+01&entry.280532864=”.$email.’&entry.1176284616=First&entry.165661554=Last’; echo $url; } If the user is logged in (if !empty ($user) ) then it grabs the data from the user variable wp_get_current_user, we could also wrap in … Read more

How do I enqueue(or delay loading of) tags in individual page posts?

General answer: you can call wp_enqueue_script() directly inline in the template, as of WordPress 3.4 (IIRC). So, if you have: <script src=”https://wordpress.stackexchange.com/questions/82668/myscriptforthispageonly.js”></script> You could replace it with: <?php wp_enqueue_script( ‘this-page-script’, get_template_directory_uri() . ‘/myscriptforthispageonly.js’, array( ‘jquery’ ), null, true ); ?> Edit From this comment: This is from within a page. As in a WordPress page. … Read more

Filter medias from the Media Uploader (wp.media) modal with a post meta

Simplest part is to filter attachment list. Use this code add_filter(‘ajax_query_attachments_args’, function($args) { $args[‘meta_query’] = array( array( ‘key’ => ‘my_image_meta’, ‘value’ => $some_value, ‘compare’ => ‘=’ ) ); return $args; }); However this code will filter all media library queries. You may want to pass some additional parameter from wp.media. This answer may be helpful.

Linking to Files in Root Directory Outside of WP Installation

Your first attempt does not work because get_template_directory_uri returns the URL to your theme directory. Your second attempt will work, but if you don’t want to hard code the domain you could either try using a root relative path or fetching the domain portion of your site url. Relative path: wp_register_script(‘circle-bounce’, ‘/js/general.js’, array( ‘jquery’, ‘jquery-effects-core’, … Read more