Custom data-id wp_enqueue_script

script_loader_tag filter was introduced in WordPress 4.1: <?php add_filter( ‘script_loader_tag’, ‘my_script_attributes’, 10, 3 ); function my_script_attributes( $tag, $handle, $src ) { // change to the registered script handle, e. g. ‘jquery’ if ( ‘MY_SCRIPT_HANDLE’ === $handle ) { // add attributes of your choice $tag = ‘<script id=”customID” data-name=”customDataName” src=”‘ . esc_url( $src ) . … 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

How can i get the title i specified in add_options_page for my header

There are a few ways you can do this. My preferred way of doing this is using Object Oriented Programming (OOP) to structure the plugin. For example, I might do this: class JPBTitle { var $page_title = “Post Products Settings”; function __construct(){ add_action( ‘admin_menu’, array( $this, ‘admin_menu’ ) ); } function admin_menu(){ add_options_page( $this->page_title, $this->page_title, … Read more

My new WordPress plugin version is not showing up in the plugin directory. It’s been 4 days what could the problem be?

@articlestack According to the trac revision log you added a new directory under your root with the same name as the plugin. It looks like your whole root directory got copied to the new directory because it contains all the tagged versions and trunk. The plugin bot will not be able to find your newly … Read more