what is diference wp_get_attachment_url / wp_get_attachment_src / get_post_thumbnail_id?

There no WordPress function wp_get_attachment_src when you want to get answer you should clear your questions and also descriptive I am giving you explanation of you question. you what is difference wp_get_attachment_url / wp_get_attachment_src / get_post_thumbnail_id? wp_get_attachment_url($id) Returns a full URI for an attachment file or false on failure. Here id is attachment post id … Read more

StudioPress: add meta tag to every page [closed]

This function should take care for the input into the head of each page/post as asked. Please make a copy of functions.php before adding following code.Adjust to your own preferences if needed. /** * Add meta to head * * Read more {@link https://codex.wordpress.org/Plugin_API/Action_Reference/wp_head} * @version WordPress 4.8 */ function wpse272951_wsm_keep_ie_modern() { echo “<meta http-equiv=\”X-UA-Compatible\” … Read more

Looping through WP_Post Object

Based on what you said about a post being completed, you can check if its status is completed and if it is, then point to the title: foreach ( $lessons as $lesson ){ if( $lesson[‘status’] == ‘completed’ ){ echo $lesson[‘post’]->post_title; } }

Passing data between two hooks in separate HTML requests

It’s not possible to pass data from one HTTP request to another one on the fly. Once the script is finished, the data will be discarded. What you can do is to store the data in a transient, and then retrieve it later. Here’s a simple example using set_transient(): set_transient( ‘my_transient’, $data, 1 * HOUR_IN_SECONDS … Read more

WordPress is executing URL in code when called via wp_mail()

Please try the following, I think having a return from the site_url() function could be creating a problem with the $confirm_url variable. That and you have an unescaped slash in your url. $site_url = site_url(); $confirm_url = $site_url. ‘\/verification?id=’ . $post_id . ‘&hash=” . $hash; // Send a verification e-mail to the user to confirm … Read more

register_rest_route regex option for base64 or alternate

I got curious, so I tested this barebone demo: add_action( ‘rest_api_init’, function () { register_rest_route( ‘wpse/v1’, ‘/post_by_permalink/(?P<path>[\S]+)’, [ ‘methods’ => WP_REST_Server::READABLE, ‘callback’ => ‘wpse_callback’, ‘show_in_rest’ => true ] ); }); function wpse_callback( $request ) { $data = [ ‘path’ => base64_decode( $request[‘path’] ) ]; return $data; } Testing: https://example.com/wp-json/wpse/v1/post_by_permalink/aHR0cHM6Ly93b3JkcHJlc3Muc3RhY2tleGNoYW5nZS5jb20vcS8zMDEwNjcv gives { path: “https://wordpress.stackexchange.com/q/301067/” } Tested … Read more

WPDB: how to get the value of a field in a custom database table

OK, so first of all, you should always use proper escaping, when building the queries. This is how your code can look after fixing: global $wpdb; $value = $wpdb->get_var( $wpdb->prepare( ” SELECT column_name FROM {$wpdb->prefix}plugin_table WHERE ID = %d “, get_current_user_id() ) ); The things you have to take care of: You have to change … Read more

Loading page template into shortcode

get_template_part takes slug as first parameter and not filename. So it should be: get_template_part( ‘template-sponsors’ ); And with more details… This function takes two parameters: get_template_part( string $slug, string $name = null ) And inside of it, the name of a file is built like this: if ( ” !== $name )         $templates[] = “{$slug}-{$name}.php”;       $templates[] = “{$slug}.php”; So, … Read more

is_page(id) not working for blog page

If the page you’re trying to check is set as Page for posts, then is_page conditional won’t be true. In such case you should check if is_home. Why? All these conditional tags are based on global wp_query. For page that is set as page for posts (home of your blog), the global query doesn’t contain … Read more