Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9132183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:16:06+00:00 2026-06-17T08:16:06+00:00

i would like to use custom post_type in my wordpress plugin but i have

  • 0

i would like to use custom post_type in my wordpress plugin but i have a problem if i will access this post_type.

if i activate my plugin i can access the for example this:
http://wp.localhost/movie_reviews/movie_test/

Generall part of class

function __construct () {

  add_action( 'init', array( &$this, 'my_int' ), 1 );

}

function my_int () { 

    add_filter( 'template_include', array(&$this, 'my_template' ), 10 );

    register_post_type( 'movie_reviews',
      array(
        'labels' => array(
        'name' => __('Movie Reviews', $this->var_sTextdomain),
        'singular_name' => __('Movie Review', $this->var_sTextdomain),
        'add_new' => __('Add New', $this->var_sTextdomain),
        'add_new_item' => __('Add New Movie Review', $this->var_sTextdomain),
        'edit' => __('Edit', $this->var_sTextdomain),
        'edit_item' => __('Edit Movie Review', $this->var_sTextdomain),
        'new_item' => __('New Movie Review', $this->var_sTextdomain),
        'view' => __('View', $this->var_sTextdomain),
        'view_item' => __('View Movie Review', $this->var_sTextdomain),
        'search_items' => __('Search Movie Reviews', $this->var_sTextdomain),
        'not_found' => __('No Movie Reviews found', $this->var_sTextdomain),
        'not_found_in_trash' => __('No Movie Reviews found in Trash', $this->var_sTextdomain),
        'parent' => __('Parent Movie Review', $this->var_sTextdomain)
      ),
      'public' => true,
      'menu_position' => 15,
      'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields', 'post-formats' ),
      'taxonomies' => array( '' ),
      'menu_icon' => plugins_url( 'img/my_icon.png', __FILE__ ),
      'has_archive' => false,
      'rewrite' => array('slug' => 'movie_reviews')
      )
    );

}

function my_template ( $template_path ) {

  if ( get_post_type() == 'movie_reviews' ) { 

        if ( is_single() ) {
          $template_path = plugin_dir_path( __FILE__ ) . '/templates/single-movie_reviews.php';
        }

        // etc ...

  }

  return $template_path;

}

On activation hoock (part of the class)

function my_int () {

    register_post_type( 'movie_reviews',
      array(
          'labels' => array(
              'name' => __('Produkt Reviews', $this->var_sTextdomain),
              'singular_name' => __('Produkt Review', $this->var_sTextdomain),
              'add_new' => __('Add New', $this->var_sTextdomain),
              'add_new_item' => __('Add New Produkt Review', $this->var_sTextdomain),
              'edit' => __('Edit', $this->var_sTextdomain),
              'edit_item' => __('Edit Produkt Review', $this->var_sTextdomain),
              'new_item' => __('New Produkt Review', $this->var_sTextdomain),
              'view' => __('View', $this->var_sTextdomain),
              'view_item' => __('View Produkt Review', $this->var_sTextdomain),
              'search_items' => __('Search Produkt Reviews', $this->var_sTextdomain),
              'not_found' => __('No Produkt Reviews found', $this->var_sTextdomain),
              'not_found_in_trash' => __('No Produkt Reviews found in Trash', $this->var_sTextdomain),
              'parent' => __('Parent Produkt Review', $this->var_sTextdomain)
          ),
          'public' => true,
          'menu_position' => 15,
          'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields', 'post-formats' ),
          'taxonomies' => array( '' ),
          'menu_icon' => plugins_url( 'assets/img/plugin.png', __FILE__ ),
          'has_archive' => true,
          'rewrite' => array('slug' => 'movie_reviews')
      )
    );

    flush_rewrite_rules();
}

// Edit: solved

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:16:06+00:00Added an answer on June 17, 2026 at 8:16 am

    Setting has_archive to true will display the post type archive at the location you mentioned.

    OR you could leave it to false and create a page with slug movie_reviews

    Make sure to visit the Permalinks settings page in your admin after you made the changes to flush the rewrite rules.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Similar to this question I would like to use dropdown plugin called dropkick, which
i would like to know how to use a custom URL with ShareThis social
I would like to use jQuery to refresh a partial on a page, but
Basically I would like to do something like this at the top of my
I would like to build my own custom DI framework based on Java annotations
Already checked this question but didn't answer. Background I have a fully functional RESTful
I am developing a facebook application and would like to post custom notifications when
I would like to change the wordpress default query to orderby title when viewing
I have a server-side zip archive that I would like to pass along as
I wrote few custom view helpers but I have a little trouble using them.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.