Skip to content

Instantly share code, notes, and snippets.

@hasanmisbah
Last active April 28, 2016 18:31
Show Gist options
  • Save hasanmisbah/15721b4c2c85353fa091fab41dad7104 to your computer and use it in GitHub Desktop.
Save hasanmisbah/15721b4c2c85353fa091fab41dad7104 to your computer and use it in GitHub Desktop.
My Personal Resource For WordPress Theme Development i also sharing it publicly For Everyone, you can add remove anything. if you wanna add something please Comment First

/**

  • Register our sidebars and widgetized areas.
  • it Contain 2 Side bar named "Left Sidebar" and "Right Sidebar" */

// Add Value Line in functions.php File

function wpb_widgets_init() {
register_sidebar( array(
	'name' => __( 'left sidebar', 'wpb' ),
	'id' => 'left-sidebar',
	'description' => __( 'The main sidebar appears on the right on each page except the front page template', 'wpb' ),
	'before_widget' => '<div class="side-index content-bg">',
	'after_widget' => '</div>',
	'before_title' => '<h3 class="list-header">',
	'after_title' => '</h3>',
) );

register_sidebar( array(
	'name' =>__( 'right sidebar', 'wpb'),
	'id' => 'right-sidebar',
	'description' => __( 'Appears on the static front page template', 'wpb' ),
	'before_widget' => '<div class="side-index content-bg">',
	'after_widget' => '</div>',
	'before_title' => '<h3 class="list-header">',
	'after_title' => '</h3>',
) );
}

add_action( 'widgets_init', 'wpb_widgets_init' );

// Add Value Line in for calling the widget

				<div>
				    <?php dynamic_sidebar( 'left-sidebar' ); ?>
				</div>
				<?php endif; ?>

// For Registering Custom Post type named Editor note // you can call it using any name by changing name, i called it editor note

// add value line in functions.php

/Editor note/

function create_posttype() {
    register_post_type( 'Editor Note',
 
    array(
        'labels' => array(
            'name' => __( 'Editor Note' ),
            'singular_name' => __( 'Editor Note' )
        ),
        'public' => true,
        'supports' => array( 'title', 'editor' ),
        'rewrite' => array('slug' => 'Editor Note'),
    )
);

} add_action( 'init', 'create_posttype' ); // add value line For call it, i skipped Post title // you can add it using

$args = array('post_type' => 'Editor Note', 'posts_per_page' => 1 ); query_posts( $args ); // The Loop while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; // Reset Query wp_reset_query(); ?>

page.php

// loop

// For title // for page content

// if have no post

Single.php

// Loop Started

// For Title // For Content
// Custom Css // For wp Comment

// if have no post

for search result

search.php

found_posts; ?> : ""

//from stack overflow

$s ); // The Query $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) { _e("

Search Results for: ".get_query_var('s')."

"); while ( $the_query->have_posts() ) { $the_query->the_post(); ?>
                <li>
                    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                </li>
             <?php
    }
}else{

?>

Nothing Found

Sorry, but nothing matched your search criteria. Please try again with some different keywords.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment