Arifur06
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Custom header for plugin single post template<?php /** * Plugin Name: Cardsof * Plugin URI: # * Description: A custom business card creator for virtual assistants. ". * Version: 1.0 * Author: Arifur06 * Author URI: # * Text Domain: crds **/ if ( ! defined( 'ABSPATH' ) ) { die( 'We\'re sorry, but you can not directly access this file.' ); } //plugin styles function nfc_card_style() { wp_enqueue_style("fontawesome",plugins_url("assets/css/fontawesome.min.css", __FILE__)); wp_enqueue_style("dark",plugins_url("assets/css/dark.css", __FILE__)); wp_enqueue_style("all-min",plugins_url("assets/css/all.min.css", __FILE__)); } add_action("wp_enqueue_scripts", "nfc_card_style"); if (!function_exists("nfc_cardz_post_type")) { // Register Custom Post Type function nfc_cardz_post_type() { $labels = [ "name" => _x("NFC Cards Zone", "Post Type General Name", "nfccz"), "description" => _x("NFC Cards Zone", "Post Type General Name", "nfccz"), "singular_name" => _x("nfc-card", "Post Type Singular Name", "nfccz"), "menu_name" => __("NFC Cards", "nfccz"), "name_admin_bar" => __("Post Type", "nfccz"), "archives" => __("Item Archives", "nfccz"), "attributes" => __("Card Attributes", "nfccz"), "parent_item_colon" => __("Parent Item:", "nfccz"), "all_items" => __("All Cards", "nfccz"), "add_new_item" => __("Add New Card", "nfccz"), "add_new" => __("Add New Card", "nfccz"), "new_item" => __("New Card", "nfccz"), "edit_item" => __("Edit Card", "nfccz"), "update_item" => __("Update Card", "nfccz"), "view_item" => __("View Item", "nfccz"), "view_items" => __("View Items", "nfccz"), "search_items" => __("Search Item", "nfccz"), "not_found" => __("Not found", "nfccz"), "not_found_in_trash" => __("Not found in Trash", "nfccz"), "featured_image" => __("Profile Image", "nfccz"), "set_featured_image" => __("Set Profile image", "nfccz"), "remove_featured_image" => __("Remove profile image", "nfccz"), "use_featured_image" => __("Use as profile image", "nfccz"), "insert_into_item" => __("Insert into item", "nfccz"), "uploaded_to_this_item" => __("Uploaded to this item", "nfccz"), "items_list" => __("Items list", "nfccz"), "items_list_navigation" => __("Items list navigation", "nfccz"), "filter_items_list" => __("Filter items list", "nfccz"), ]; $args = [ "label" => __("nfc-card", "nfccz"), "description" => __( "You can add individual cards in this post type", "nfccz" ), "labels" => $labels, "supports" => ["title", "thumbnail", "editor"], "hierarchical" => false, "public" => true, 'menu_icon' => 'dashicons-index-card', "show_ui" => true, "show_in_menu" => true, "show_in_admin_bar" => true, "show_in_nav_menus" => true, "can_export" => true, "has_archive" => false, "exclude_from_search" => true, "publicly_queryable" => true, "capability_type" => "page", ]; register_post_type("nc", $args); } add_action("init", "nfc_cardz_post_type", 0); } require_once "options/init.php"; require_once "options/options.php"; require_once "shortcode.php"; // single post add_filter( 'single_template', 'override_single_template' ); function override_single_template( $single_template ){ global $post; $file = dirname(__FILE__) .'/templates/single-'. $post->post_type .'.php'; if( file_exists( $file ) ) $single_template = $file; return $single_template; }
Forum: Developing with WordPress
In reply to: Custom header for plugin single post template<?php get_header('custom');?> <div class="ful-area"> <div class="bg-area"> <div class="cont-area"> <div class="avatar"> <img src="<?php echo get_post_meta(get_the_ID(), "nfc_avatar", true); ?>" alt=""> </div> <div class="name"> <a href="<?php the_permalink(); ?>"><h2><?php echo get_post_meta(get_the_ID(), "nfc_name", true); ?> </h2></a> </div> ? ? ? ? ? ?<div class="designation"> ? ? ? ? ? ? ? ?<h3><?php echo get_post_meta(get_the_ID(), "nfc_desig", true); ?> </h3> <h4><?php echo get_post_meta(get_the_ID(), "nfc_company", true); ?> </h4> <div class="bio"> <?php the_content(); ?> </div> </div> <div class="contact-icon"> <?php $contactdet = get_post_meta(get_the_ID(), "_nfc_con_details", true );?> <?php foreach ($contactdet as $singcontact): $nfc_contact_icon = $singcontact['_nfc_con_icon']; ?> <div class="email-icon"> <a href="<?php echo esc_url($singcontact['_nfc_con_link']);?>"><i class="<?php echo esc_attr($nfc_contact_icon);?> con-icon"></i> <div class="contact-info"> <div class="email"><?php echo esc_html($singcontact['_nfc_con_title']);?></div> <div class="email-text"><?php echo esc_html($singcontact['_nfc_con_info']);?></div> </div></a> </div> <?php endforeach; ?> </div> <div class="social"> <div class="social-icon"> <div class="social"> <div class="social-icon"> <?php get_header('nfcs');?> <div class="ful-area"> <div class="bg-area"> <div class="cont-area"> <div class="avatar"> <img src="<?php echo get_post_meta(get_the_ID(), "nfc_avatar", true); ?>" alt=""> </div> <div class="name"> <a href="<?php the_permalink(); ?>"><h2><?php echo get_post_meta(get_the_ID(), "nfc_name", true); ?> </h2></a> </div> ? ? ? ? ? ?<div class="designation"> ? ? ? ? ? ? ? ?<h3><?php echo get_post_meta(get_the_ID(), "nfc_desig", true); ?> </h3> <h4><?php echo get_post_meta(get_the_ID(), "nfc_company", true); ?> </h4> <div class="bio"> <?php the_content(); ?> </div> </div> <div class="contact-icon"> <?php $contactdet = get_post_meta(get_the_ID(), "_nfc_con_details", true );?> <?php foreach ($contactdet as $singcontact): $nfc_contact_icon = $singcontact['_nfc_con_icon']; ?> <div class="email-icon"> <a href="<?php echo esc_url($singcontact['_nfc_con_link']);?>"><i class="<?php echo esc_attr($nfc_contact_icon);?> con-icon"></i> <div class="contact-info"> <div class="email"><?php echo esc_html($singcontact['_nfc_con_title']);?></div> <div class="email-text"><?php echo esc_html($singcontact['_nfc_con_info']);?></div> </div></a> </div> <?php endforeach; ?> </div> <div class="social"> <div class="social-icon"> <div class="social"> <div class="social-icon"> <?php $nfccarddetails = get_post_meta(get_the_ID(), "_nfc_card_details", true );?> <?php foreach ($nfccarddetails as $singcard): ? ? ? ? ? ? ? ? ? ? ? ? ? ? $nfc_f_icon = $singcard['_nfc_social_icon']; ?> <a href="<?php echo esc_url($singcard['_nfc_social_link']);?>"><i class="fa-brands <?php echo esc_attr($nfc_f_icon);?> icons-round"></i></a> <?php endforeach; ?> </div> </div> </div> </div> <div class="save-btn"> <a href="<?php echo get_post_meta(get_the_ID(),"nfc_btn_link",true); ?>"><?php echo get_post_meta(get_the_ID(),"nfc_btn_text",true); ?></a> </div> </div> </div> </div> ? <?php get_footer('custom');?>
i created blank header and footer in theme files then call it in custom post type ‘singke-template.php here
Forum: Developing with WordPress
In reply to: Custom header for plugin single post templateyes. Correct
Forum: Developing with WordPress
In reply to: Custom header for plugin single post templateThanks for your reply.
i did this using child theme but when i change theme i had to add child theme and declare header again.. That is why I wanted to keep it in plugin. So that i can use the plugin in any theme when i declare a blank header and footer from plugin directory.
regards
Forum: Developing with WordPress
In reply to: Custom header for plugin single post templateHi. Thanks for reply.
I want In single template (custom post type) will not show the header and footer. I added an header-custom.php and footer-custom.php in theme file.
And declared header from plugin single.php this way.
<?php get_header (‘custom’)?> and <?php get_footer (‘custom’?>
When the theme get updates the header_custom.php and footer-custom.php are deleted and I have to upload the custon header again..
so I want to include header in plugin file.
Regards: