How to get access the ID of all posts of custom post type in Gutenberg editor

var el = wp.element.createElement var withSelect = wp.data.withSelect wp.blocks.registerBlockType(‘voucher/shortcode’, { title: ‘Voucher Shortcode’, icon: ‘smiley’, category: ‘common’, attributes: { category: { type: ‘string’, } }, edit: withSelect( function( select ) { var pages = select(‘core’).getEntityRecords(‘postType’, ‘voucher’, { per_page: -1 }); return { posts: pages }; } ) (function(props) { if ( ! props.posts ) { … Read more

Plugins Settings page not updating

I don’t know why this happened, but it seems that register_setting shouldn’t be in the callback of add_settings_field // no actual code // this worked add_settings_field(‘id’,’title’, /*callback*/ function($arguments) {echo $htmlcode;}), ‘page’, ‘section’); register_setting(‘option_group’, ‘option_name’); I hope this helps

Add custom html classes to gutenberg wrapper

Block Filters are used to customize the class that wordpress already adds using following format wp-block-[plugin_name]-[block-name]. You can access that using this.props.className. You can also add the additional classes using Advanced Panel which is present on right sidebar. In the end you can use React.js component state to define custom classes (pseudo code is given … Read more

How to save multiple values in custom post type from front end to back end

wp_insert_uses (trac) the following loop to handle meta_input, if ( ! empty( $postarr[‘meta_input’] ) ) { foreach ( $postarr[‘meta_input’] as $field => $value ) { update_post_meta( $post_ID, $field, $value ); } } So if you change meta_input in your new post args to be like this, ‘meta_input’ => array( ‘invocies’ => array( ‘service’ => $_POST[‘service’], … Read more

Changing author slug for a custom role without using plugin

You can use add_permastruct() (with ep_mask set to EP_AUTHORS) to add the proper rewrite rules, and the author_link filter to set the proper author URL: add_action( ‘init’, function(){ add_permastruct( ‘%author_trip_vendor%’, ‘operator/%author%’, [ ‘ep_mask’ => EP_AUTHORS, ] ); } ); add_filter( ‘author_link’, function( $link, $author_id, $author_nicename ){ if ( user_can( $author_id, ‘trip_vendor’ ) ) { $link … Read more