add button to specific post

Assuming that the hook you have used is correct; below is the updated code which you can use: function custom_listify_single_job_listing_actions_after() { global $post; if( $post->ID == 1464 ) { $url = get_post_meta( $post->ID, ‘your_custom_meta_key’, true ); echo ‘<a href=”‘ . esc_url( $url ) . ‘” class=”button”>My Button</a>’; } } add_filter( ‘listify_single_job_listing_actions_after’, ‘custom_listify_single_job_listing_actions_after’ ); Let me … Read more

How to replace the default domain on wp get shortlink

You can filter the link returned by wp_get_shortlink() using get_shortlink filter. add_filter( ‘get_shortlink’, ‘cyb_replace_domain_shortlink’ ); function cyb_replace_domain_shortlink( $shortlink ) { return str_replace( ‘mydomain.com’, ‘myalternatedomain.com’, $shortlink ); }

Calling PHP Titles inside Javascript Markup

First, don’t echo your php, but assemble everything in a string, let’s say $titlestring. Next, make this string available for access by the javascript (the slug is the one you used to register the script): $params = array ( ‘titlestring’ => $titlestring, ); wp_localize_script (‘your-script-slug’, ‘IframeTitle’, $params); Finally, access the variable in the script: ‘<div … Read more

Get wp_current_user_id using PHP and MySQL

Thanks to @Samuel Elh I manage to get this done. I added this to my order-confirmation.php after I included config.php require (‘../wp-blog-header.php’); global $wpdb; global $current_user; get_currentuserinfo(); $skrivID = $current_user->ID; Then the insert query, I added the table I wanted the user ID stored in and used the variable $skrivID as value. $sql = mysqli_query($db_conn, … Read more

Add URL parameter to all internal links using a specific theme

You can set the $_GET global internally. By saving the parameter passed as user meta and/or a cookie and retrieving it later. This would probably have to be put in your /wp-content/mu-plugins/ folder to work properly (so it is loaded early): <?php $parameter=”theme”; // default for theme test drive $savemethod = ‘both’; // ‘usermeta’ (only), … Read more

Conditional featured image with youtube thumbnail

There are three problems 1. echo and php tags within an echo Change your first echo from: echo ‘<img src=”http://img.youtube.com/vi/<?php echo get_post_meta($post->ID,’video_url’,true);?>/0.jpg”/>’; to this: echo ‘<img src=”http://img.youtube.com/vi/’ . get_post_meta($post->ID,’video_url’,true) . ‘/0.jpg”/>’; 2. if statement not wrapped and no brackets change: if get_post_meta($post->ID,’video_url’,true) to: if (get_post_meta($post->ID,’video_url’,true)) and add {} around that code block: if (get_post_meta($post->ID,’video_url’,true)) { … Read more