Last active
August 29, 2015 14:16
-
-
Save shahadat014/f980cdd0d269b9575963 to your computer and use it in GitHub Desktop.
menu,widget,custom post registration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//custom post register................. | |
<?php | |
function custom_post_register(){ | |
register_post_type('slide', array( | |
'public' => true, | |
'label' => 'slide', | |
'labels' =>array( | |
'name' => 'slides', | |
'singular_name' => 'slide', | |
'add_new' => 'add new slide', | |
), | |
'supports' =>array('title', 'editor', 'thumbnail', 'excerpt', 'custom-fields', 'page-attributes') | |
)); | |
} | |
add_action('init', 'custom_post_register'); | |
//post query for any custom post............... | |
<?php | |
global $post; | |
$args = array( 'posts_per_page' =>4, 'post_type'=> 'service', 'orderby' => 'menu_order', 'order' => 'ASC' ); | |
$myposts = get_posts( $args ); | |
foreach( $myposts as $post ) : setup_postdata($post); ?> | |
<?php | |
$service_icon= get_post_meta($post->ID, 'service_icon', true); | |
$service_link= get_post_meta($post->ID, 'service_link', true); | |
?> | |
<div class="col-lg-3"> | |
<div class="box"> | |
<div class="box-gray aligncenter"> | |
<h4><?php the_title(); ?></h4> | |
<div class="icon"> | |
<?php the_post_thumbnail('large'); ?> | |
<i class="fa fa-<?php echo $service_icon; ?> fa-3x"></i> | |
</div> | |
<?php the_excerpt(); ?> | |
</div> | |
<div class="box-bottom"> | |
<a href="<?php echo $service_link; ?>">Learn more</a> | |
</div> | |
</div> | |
</div> | |
<?php endforeach; ?> | |
//widget register code.......... | |
<?php | |
function moderna_theme_widgets(){ | |
register_sidebar(array( | |
'name' => __( 'footer widgets', 'sadia' ), | |
'id' => 'footer_wid', | |
'description' => 'This widget use for your site footer content.', | |
'before_widget' => '<div class="col-lg-3"><div class="widget footer_widget">', | |
'after_widget' => '</div></div>', | |
'before_title' => '<h5 class="widgetheading">', | |
'after_title' => '</h5>', | |
)); | |
} | |
add_action('widgets_init', 'moderna_theme_widgets'); | |
//call page location for widget | |
<?php if( ! dynamic_sidebar('footer_wid') ) : ?> end <?php endif; ?> | |
//widget support schortcode for function php | |
include_once('inc/widgets.php'); | |
add_filter('widget_text', 'do_shortcode'); | |
//menu registration | |
<?php | |
function alphp_manus(){ | |
register_nav_menus(array( | |
'top_menu' => 'top menu', | |
'main_menu' => 'Main Menu', | |
)); | |
} | |
add_action('init', 'alphp_manus'); | |
function alpha_fallback_menu(){ | |
echo '<ul class="top-nav-menu">'; | |
if ('page' != get_option('show_on_front')) { | |
echo '<li><a href="'. site_url() . '/">home</a></li>'; | |
} | |
wp_list_pages('title_li='); | |
echo '</ul>'; | |
} | |
// menu query code | |
<div class="top-nav-right" > | |
<?php wp_nav_menu( array( | |
'menu_class' => 'top-nav-menu', | |
'theme_location' => 'top_menu', | |
'fallback_cb' => 'alpha_fallback_menu', | |
) ); ?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment