Custom Meta Box returns no HTML

Try adding array( $this, ‘myskills_html’ ) to the third argument. public function skillsmetabox_init() { add_meta_box( ‘myskills_meta’, ‘Proficiency’, array( $this, ‘myskills_html’ ) ); } Since this is class method, it should have the $this as well. The same way you did with add_action( ‘save_post’, array( $this, ‘save_metabox_details’ ) );

WordPress CPT custom custom label

You can add anything up there with the ‘in_admin_header’ action. Example (pseudo code): add_action( ‘in_admin_header’, function() { if ( … check $post_type, $pagenow etc, to target right page only … ) { echo ‘<p>Hello editor</p>’; } } );

Convert comma separated list to serialized array to import as post meta

If you need to do this conversion in PHP, as part of whatever import process, then you can just convert the comma-separated values into an array with explode(), and then use update_post_meta(), which will automatically serialise the value for you: $value=”Morning,Daytime”; $array = explode( ‘,’, $value ); update_post_meta( $post_id, ‘hours_of_operation’, $array ); Use trim() if … Read more

Pagination hitting 404 page on /page/4

Just in case anyone ever stumbles across this, I found the solution. First step was to create an archive.php page In there I would access the loop. The in functions.php I have a category rewrite filter to update the category rewrite rules to use the following example url index.php?wpdmcategory=category-name&paged=2 when I hit /category-name/page/2 Previously, it … Read more

Want a custom query with just one category but from all custom post types

category_name should take a string, not an array I believe post_type is not mentioned as an arg, and thus defaults to ‘post’ so try: $args = array( ‘post_type’ => ‘any’, //or use cpt slug as string, or array of strings if multiple ‘category_name’ => ‘budget’, //use ‘budget,premium’ if you want posts with budget OR premium, … Read more

Custom Post Type Category URL

Option 1: Enable the post type archives and use a post type archive template. Enable the archives; e.g. when registering the post type using register_post_type(): register_post_type( ‘shop’, [ ‘has_archive’ => ‘shop’, // the archives are accessible at example.com/shop // … ] ); Then create a custom archive template just for that post type; i.e. archive-shop.php. … Read more

ACF for custom post type archive pages: which hook to use?

Is this a sequence mismatch between the hooks? I would argue so, yes. acf/init gets executed by class ACF’s init method, all in the root file acf.php – this method is hooked to WordPress’ init with a priority of 5 like so add_action( ‘init’, array($this, ‘init’), 5 ); And you probably add your CPTs with … Read more

Should Custom post types and fields be in the theme files or in a custom plugin packed into the theme?

You will be rejected from the WordPress.org theme direcotry if you include these post types in the theme. The guidelines, which are available here, state: Non-design related functionality is not allowed. (See: Plugin territory examples) And one of the examples is: Custom Post Types and Shortcodes Regarding TGM, the guidelines have this to say: Themes … Read more