Cannot get transient to work on shortcode, Moz API

You need to return $seo_grade outside the if i.e. at the very end of your function – at the moment you’re saying “if no transient, create one and return it, otherwise return nothing”. Also at the top, you return $seo_grade if the domain is “NULL”, but the variable will be undefined (possible typo – you’re … Read more

basic wordpress api endpoint to serve a key-value dictionary

You could create your own WP REST API endpoint that handles this. To register a custom endpoint: add_action( ‘init’, ‘bootstrap_api’ ); function bootstrap_api() { add_action( ‘rest_api_init’, ‘my_api_endpoint’ ); } function my_api_endpoint() { register_rest_route(‘myapi/v1’, ‘get/words’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘return_word_list’, ) ); } function return_word_list() { // Do someting to build your list of … Read more

Querying Posts Using JSON API

I found this this url got me the results I needed – http://scd.blaze.wpengine.com/wp-json/posts?type=listings&filter[listing_area]=channel my post type being listings and the slug of my term channel

Programmatically add a Navigation menu and menu items

I might be misunderstanding you, but why not use wp_create_nav_menu()? E.g., this is what I do to create a custom BuddyPress menu when I detect BP as active: $menuname = $lblg_themename . ‘ BuddyPress Menu’; $bpmenulocation = ‘lblgbpmenu’; // Does the menu exist already? $menu_exists = wp_get_nav_menu_object( $menuname ); // If it doesn’t exist, let’s … Read more

Surrogate ID for posts, is there an alternative field in the posts table?

It depends on how are you importing those posts. You can use wp_insert_post() with import_id: $postToBeInserted = array( ‘post_title’ => ‘Your Post Title’, ‘post_content’ => ‘Your post content…’, ‘import_id’ => 154 ); wp_insert_post($postToBeInserted); If there is no post with the specified import_id the post will have that ID. That way you won’t have to deal … Read more

Create new product with woocommerce REST API with javascript (clientside)?

If you’re using SSL (HTTPS URL) you don’t need to use oauth1.0 with oauth signature and everything. All you need to do is pass in the consumer_key and consumer_secret in the url https://localhost/wpShop/wc-api/v2/products?consumer_key=ck_1111111111122123&consumer_secret=cs_232332322233232 That’s it! However, if your URL is NOT SSL, then you have to go to the trouble of creating an HMAC-SHA1 keys … Read more

Order Posts By Youtube Views

https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters <ul> <?php $item=0; $attr = array( ‘post_type’ => ‘lyrics’, ‘date_query’ => array( array( ‘after’ => ‘1 month ago’ ) ), ‘post_status’=> ‘publish’, ‘meta_key’ => ‘youtube_views’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 10 ); $loop = new WP_Query( $attr ); while ( $loop->have_posts() ) : $loop->the_post(); $song_name = get_the_title(); /*YOUTUBE QUERY HERE*/ // … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)