Share functions between admin and frontend

That boilerplate uses autoloading, take advantage of it! I understand it’s a bit overwhelming but with some training you will realize that autoloading and OOP are a superlative productivity boost. Inside inc/common create your class (for example, class-commonclass.php) <?php namespace PGC_Signoffs\Inc\Common; \\declare the namespace for autoloading class CommonClass { public function commonFunction($a,$b,$c){ //could also be … Read more

Author Meta in Author URL Link

This is just an example / idea and I haven’t tested if this really works. But I think it could be something along these lines. function custom_author_base() { global $wp_rewrite; global $wp_query; // On author pages you get current author for example with $wp_query $curauth = $wp_query->get_queried_object(); // Get the required data $country = get_user_meta($curauth->ID, … Read more

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