Wordpress: How to disable custom post type imported in a theme? - wordpress

I have installed Linoor theme which contains a post type called 'Events'. I want to implement the Events submission form for admin as well as visitors. The plugin Events Manager provides this facility for visitors to submit their events with admin approval. However, the plugin doesn't override the post type created by the theme. Also, in the admin side the 'Events' post type as duplicated fields for Event Address, location, timings, etc.
Is there a way to disable or remvoe this post type? Or hide/remove/disable the fields while creating a new event?
I looked up the theme and plugin's documentation but couldn't find the prooper way to solve this.

you can use simply this code in functions.php
function remove_post_type(){
unregister_post_type( 'events' );
}
add_action('init','remove_post_type', 100);

You can use unregister_post_type with CPT's slug.
Reference:
https://wordpress.stackexchange.com/questions/3820/deregister-custom-post-types

Related

CPT instead of WooCommerce "Product"

I have a problem that hopefully you will help me solve.
I'm am pretty new with this job and don't know pretty much anything about coding yet. I built some websites using Elementor but never touched WooCommerce before and now I am working on a real estate website with lots of houses uplouded as a Custom Post Type (which I will call "ANN").
My problem is: my client wants to have a live catalogue of the selling houses for ADS and stuff.
Searching the Web I figured out that WooCommerce is the best way to do it even if I don't need the shopping cart (if you have other ideas are welcome) but as far as I understand WC have ITS OWN CPT "Product" and I wonder how canI set it to use my ANN instead of PRODUCT to the listing?
Is that possible?
The main problem is that there are lots of real estate ads already uplouded so change them is a no go.
I'm using JetEngine plugin for the CPT, Filters, etc.. if this can help somehow.
Thank you for you time!
You could achieve that with the Advanced Custom Fields plugin, but you're gonna need elementor pro.
You can create all the additional fields for the information you need to be displayed in that post type using ACF.
See this link for more information: Creating a Field Group
Make sure your custom post type supports custom fields, if you created it with the CPT UI plugin, you can check that by editing your custom post type and scrolling all the way down. You should see a section with a list of things supported by your custom post type, check custom fields and save.
Then create a template for the custom post type using Elementor's theme builder: How to Create a WordPress Single-Post Template in Elementor
Add the custom fields to the template using the ACF integration with Elementor: Elementor Integration With ACF
Lastly, create a custom loop for your custom post type archive using the Elementor custom skin plugin, so yiu can display the custom fields also in the archive if you need to:
How to display posts in Elementor Pro with your own Design (Elementor Custom Loop)

WordPress. Adding a taxonomy both to users and other content

As reported in this page adding a taxonomy to a user is very different and more complicated than doing the same job for anoter content.
That's my question: can I add the taxonomy, let's call it "skills", to my users and to a CPT called JobOffer?
How... in case it's possible?
Many thanks
There are several ways. An easy solution is to use Advanced Custom Fields to add taxonomies for a custom post type to users.
Have you already registered the custom post type taxonomy and linked it to the custom post type?

Woocomerce - how to add custom HTML widget in admin area? Edit order, edit product views?

I want to add a widget with custom HTML in it, how can I do it?
It has to be placed in 2 places:
woocomerce order edit view
woocomerce product edit view
The order and product are custom post types. You'll want to use
add_action( 'add_meta_boxes', 'yourfunction' );
and within yourfunction, call wordpress's add_meta_box(); function.
The 3rd parameter to add_meta_box() is the function which outputs HTML. This is where you can output the div mount point for your react app. The admin_enqueue_scripts action is where you can enqueue your javascript into the admin dashboard.
If you google for something along the lines of "add meta box to custom post type" you'll find some blogs with examples.
https://developer.wordpress.org/reference/functions/add_meta_box/
Got this answer at Facebook group from Brian, sharing it here for future googlers :)

Add Custom Post Type Custom Fields to WordPress Search

I've created a custom post type for a client (gravesite), and it has several custom fields to fill out ('bcva_branch_text', 'bcva_rank', 'bcva_start_serve', 'bcva_end_serve', 'bcva_dob', 'bcva_dod', 'bcva_cemetary', 'bcva_latitude', 'bcva_longitude').
The client wants these fields to be searchable, but I'm having trouble finding a way to do it. The WordPress Search will search the custom post type's title and 'editor' fields, but how do I get WP to search the added custom fields as well?
Thanks!
The Custom Fields Search plugin looks like it will do what you need. It seems to let you choose which custom fields will be included in search.

How to create Custom field in Custom Post-type

I've a custom post-type "video" and i enabled custom fields already.
i need to create three custom fields, 1. video file, 2. video url, 3. video code.
i tried couple of tutorials on tutsplus and other sites but not get working as i need.
anyone can help.
Wordpress has a built in api function, add_meta_box which you can use to output the form fields for your post meta. in the post_type argument you need to put 'video'
In order to capture the form input you need to use the save_post action, take a look here
Easiest way is to use a plugin like Advanced Custom Fields. You'll have a nice interface to add your custom fields and to choose on which post type to show them.

Resources