How to access specific product id on other pages/posts?

Thanks the Tony Djukic coment, here is a working code example: <?PHP $product_id = 92; /*hard code the product id */ $manufacture_url = get_field( “manufacture_url”, $product_id, true ); echo ‘some html’ + $manufacture_url + ‘some html’ ?> The product ID can be found in the product URL on editing mode. I used xyz PHP plugin … Read more

Force REST API Authentication for each request method

You can’t really apply authentication based directly on whether the request is GET or otherwise, but can forcefully apply authentication requirements globally in that manner, if you like. I’ve been quite verbose with the code to illustrate what’s happening: add_filter( ‘rest_authentication_errors’, function ( $error ) { /** * If it’s a WP_Error, leave it as … Read more

Display the list of user’s comments + the post title + date

add this snippet for according your needed: add_shortcode ( ‘show_recent_comments’, ‘show_recent_comments_handler’ ); function show_recent_comments_handler( $atts, $content = null ) { extract( shortcode_atts( array( “count” => 10, “pretty_permalink” => 0 ), $atts )); $output=””; // this holds the output if ( is_user_logged_in() ) { global $current_user; get_currentuserinfo(); $args = array( ‘user_id’ => $current_user->ID, ‘number’ => $count, … Read more

Where to add my PHP codes for AJAX Jquery to work?

Here is a general scenario for adding PHP code snippets in WordPress theme or plugin. Scenario 1: Theme is your custom made theme. In this case, you can add code snippets in your own desired way (and obviously in standard way since you are the author of the theme). Scenario 2: Theme is either premium … Read more

Cant get blog name with get_option

You need access to the property of $username to get the name $user = wp_get_current_user(); $username= $user->display_name; Get option method will return the name of the site you have set in setting -> general options $url = get_option( ‘blogname’); If you need home URL then $url = get_option( ‘home’ );