How do I create a state of “don’t assign anything to variable” if WP_Error throws an error?

Looks like the line giving you the error is rather this one $data = json_decode( $this->get_json(), true); Like this (untested) it should work: private function get_data() { /** * Ingests the data from get_json() then converts / decodes into an array. */ $json = $this->get_json(); if (is_wp_error($json)) { return new WP_Error( ‘invalid-data’, esc_html__( ‘Something is … Read more

Bootstrap carousel – Using shortcode inside enclosing shortcode

Here is my solution: function getProductCarousel($atts) { $productIds = explode(‘,’,$atts[‘product_ids’]); ?> <div class=”col-center m-auto”> <div id=”myCarousel” class=”carousel slide” data-ride=”carousel” data-interval=”0″> <!– Carousel indicators –> <ol class=”carousel-indicators”> <?php $slide = 0; ?> <?php foreach($productIds as $index => $productId) { ?> <?php if ($index % 3 == 0) { ?> <li data-target=”#myCarousel” data-slide-to=”<?= $slide++; ?>” <?= $index … Read more

Can i add custom code in Source in specific page, Header from function.php?

You can add conditions in you function if you want to add icons like this method you mentioned in question. function hook_link() { global $post; if ($post->post_type == ‘page’ && $post->ID == ‘whatever page id’) { echo ‘<link href=”http://buhehe.de/wp-content/uploads/2017/12/Buhehe.ico” rel=”shortcut icon” type=”image/x-icon”>’; } ?> <?php } add_action(‘wp_head’, ‘hook_link’); to check page or post etc you … Read more