Create metaboxes based on custom post type

When defining your MetaBox before registering it, just set the PostTypes it is applicable for: $f711_meta_boxes[] = array( ‘id’ => ‘details’, ‘title’ => __( ‘Details’, ‘f711_theme’ ), ‘pages’ => array( ‘publicity’ ), // change this values ‘context’ => ‘normal’, ‘priority’ => ‘high’, ‘fields’ => array( array( ‘name’ => __( ‘Fischi ist’, ‘f711_theme’ ), ‘desc’ => … Read more

plugin shortcode not working on ajax request call

…ajax calls can’t show shortcodes because of the admin ajax url that they dont have full access to wordpress enviorment Not true. AJAX calls have exactly the same resources at their disposal as regular WordPress requests. Just make sure to parse the content in the same way the_content() does: $parsed_content = apply_filters( ‘the_content’, $post->post_content ); … Read more

Adding Static Image to WooCommerce Content-Single-Product template

Many thanks to Nathan Powell for the fix. Changing get_stylesheet_directory() to get_stylesheet_directory_uri() will return the correct URL. get_stylesheet_directory() returns the absolute server path to child or parent theme (hence my previous issue) whereas get_stylesheet_directory_uri() returns the properly formed URI of child or parent theme. I suppose the lesson is to pay close attention to exactly … Read more

A question about register_activation hook

The register_activation_hook() is actually just a wrapper for add_action(‘activate_’ . $file, $function); and is only executed when a plugin is activated. This action/function is meant to be used by anything that should only execute once when the plugin is activated, things which would include stuff like adding custom terms to taxonomies create new database tables … Read more

Repeated Output in Widget

Your widget markup is broken! Check this line $phone_link = ‘<a class=”contact-phone” href=”https://wordpress.stackexchange.com/questions/221244/tel:%s” itemprop=”telephone”>%s</span>’; Opening tag is <a> and closing tag is </span>. Correct it with $phone_link = ‘<a class=”contact-phone” href=”https://wordpress.stackexchange.com/questions/221244/tel:%s” itemprop=”telephone”>%s</a>’;

How can I delete a wordpress widget instance?

Widgets should only be manipulated by users, and in general they should not be deleted because there is no version control for them. Therefor I suggest you rethink first before reading further. Widgets are located in two places in the DB, the sidebar_widgets option is an array of sidebars, indexed by the sidebar id. Each … Read more