Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

 The custom plugin is the best way to implement plugin functionality by code.


We can inherit all features of POST to create Custom Plugin


<?php

/*


plugin name:  MOVIES Plugin


description:-  ADD MOVIE


*/


function create_posttype() {

register_post_type( 'news',

// CPT Options

array(

  'labels' => array(

   'name' => __( 'news' ),

   'singular_name' => __( 'News' )

  ),

  'public' => true,

  'has_archive' => false,

  'rewrite' => array('slug' => 'news'),

 )

);

}

// Hooking up our function to theme setup

add_action( 'init', 'create_posttype' );


?>


How to call the plugin on code:-



<?php

/*Template Name: News*/

get_header();

query_posts(array(

   'post_type' => 'news'

)); ?>

<?php

while (have_posts()) : the_post(); ?>

<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>

<p><?php the_excerpt(); ?></p>

<?php endwhile;

get_footer();

?>







Post a Comment

POST Answer of Questions and ASK to Doubt

Previous Post Next Post