I want to create new form on wordoress admin panel for store data by admin, for example i have one student detail and i want store through admin panel.
Please let me know.....
Best
Abhishek
Why dont you create a new post type? http://codex.wordpress.org/Post_Types
You can set this to not show publicly. You could some something like this:
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'acme_product',
array(
'labels' => array(
'name' => __( 'Products' ),
'singular_name' => __( 'Product' )
),
'public' => false,
'has_archive' => true,
)
);
}
Related
I have a created custom post type using this code,
function adsManager_custom_post_type(){
register_post_type('adsmanager_banner',
array(
'labels' => array(
'name' => __('Banners', 'textdomain'),
'singular_name' => __('Banner', 'textdomain'),
),
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-admin-page',
'rewrite' => array( 'slug' => 'banners' ),
'supports' => array(
'title',
'editor',
'short-code'
)
)
);
}
add_action('init', 'adsManager_custom_post_type');
Now I want to automatically add a shortcode for each custom-post-type (banner) when user creates a new banner and then show the shortcode for each banner in banners screen like,
You have plenty of options if you are looking for an hook after the post is saved. They all comes from the same file which is:
wp-includes/post.php
In that file you can find this action and many more:
do_action( "save_post_{$post->post_type}", $post->ID, $post, true );
After you hook in that you can have this:
add_action('save_post_mycpt','afterMyCptIsSaved');
function afterMyCptIsSaved($postId,$post,$update){
....
your code
....
}
Hello i have one cpt which is case studies but i want to rename it as portfolio .and i have created 10 post under case studies cpt .. so can i rename it cpt ? actually i want change in url .. currently my url is http://www.praxinfo.com/case-studies-page/whatscrackin/ but i want http://www.praxinfo.com/portfolio/whatscrackin/. so how to do this in wordpress?
In your register_post_type use the rewrite option to change the url but not the actual name of the cpt. This way, you won't run into database problems and your users will still see the new name.
Example from the WordPress codex:
add_action( 'init', 'create_posttype' );
function create_posttype() {
register_post_type( 'acme_product',
array(
'labels' => array(
'name' => __( 'Products' ),
'singular_name' => __( 'Product' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'products'),
)
);
}
Here, the url would be /products/ even though the name of the cpt is acme_product.
I am working on a wordpress website. I need to add custom Post types. I have created a custom post type products which has a taxonomy product_type which is similar to category . There are various taxonomy value for product_type . Some of them are flowers, extracts etc .
Now I am trying to visit this link http://farma.mechadigital.net/products/product_type/flowers/ and it doesnt work for me.
I have added some files.
archive-products => This should be the custom post template
taxonomy-product_type.php => This should be the taxonomy Template
taxonomy-product_type-flowers.php => This should be the template for the term value flowers
Here is the code that I have included in functions.php. I dont know where I am doing it wrong.
functions.php
function farma_products() {
$labels = array(
// List of arguments
);
$args = array(
// list of arguments
'rewrite' => array( 'slug' => 'products' ),
);
register_post_type( 'products', $args );
flush_rewrite_rules(false);
}
add_action( 'init', 'farma_products_type' );
function farma_products_type() {
register_taxonomy(
'product_type',
'products',
array(
'label' => __( 'Product Type' ),
'rewrite' => array( 'slug' => 'products/product_type' ),
'hierarchical' => true,
)
);
}
I'm not talking about adding an attribute to a product but I want to add an attribute itself..
You can do that from the UI under Products -> Attributes but from the code how is it done (e.i: what functions to call or tables to update)?
An attribute is merely a custom taxonomy, so I think you should be able to do this the same as you'd register any custom taxonomy. WooCommerce prefaces their attributes taxonomy names with 'pa_' (probably standing for product attibute)
add_action( 'init', 'create_product_attribute' );
function create_product_attribute() {
register_taxonomy(
'pa_genre',
'product',
array(
'label' => __( 'Genre' ),
'rewrite' => array( 'slug' => 'genre' ),
'hierarchical' => true,
)
);
}
I have just registered a new Custom Taxonomy in Wordpress (as per the docs). Here is a copy of the code in functions.php for reference:
function people_init() {
// create a new taxonomy
register_taxonomy(
'people',
'post',
array(
'label' => __( 'People' ),
'rewrite' => array( 'slug' => 'person' ),
'capabilities' => array(
'assign_terms' => 'edit_guides',
'edit_terms' => 'publish_guides'
)
)
);
}
add_action( 'init', 'people_init' );
As you can see in the image below, the Taxonomy appears within left-hand navigation but when my (admin) user clicks on the option I am displayed with an You are not allowed to edit this item. error:
Can anyone suggest why this may be?
Almost as soon as I posted this I realised it is the capabilities array. Removing this, so that it reverts to the default allows access as intended.
After further investigation I found that the following was the best settings to get this functioning correctly:
'capabilities' => array(
'manage__terms' => 'edit_posts',
'edit_terms' => 'manage_categories',
'delete_terms' => 'manage_categories',
'assign_terms' => 'edit_posts'
)