• Hi,

    I have website with single WP-installation. I have lot of types of custom contents- video, music

    1. I have used default pages type for fixed page such as about us, contact etc
    2. I have used default post type for blog
    3. Videos for video and music for music

    In my custom theme, I have create archive-video.php, video.php, archive-music.php, music.php templates to list music and videos in different layout format. page type are displayed using php.php and posts are handled by index.php and single.php.

    URL for each content type are

    1. Video – mysite.com/video
    2. Music – mysite.com/music
    3. Blog and Page – mysite.com

    Now, I need to change Blog url as mysite.com/blog. I am able to do so by adding prefix blog in permalink structure from (WP-Admin -> Settings -> Permalink, Custom structure)

    Problem start here, URL for music and video do not work. They need to be access mysite.com/blog/video and mystie.com/blog/music (blog is added on each)

    I want to work, mysite.com/video, mysite.com/music, mysite.com/blog (with single WP installation).

    Any suggestion, how can I acheive this

Viewing 3 replies - 1 through 3 (of 3 total)
  • You should be able to create a page called “Blog”, and then under “Settings”–>”Reading” pick a page to be used as the home page, and a page to be used for the blog page. When you do this, the page “Blog” will use the index.php template by default and should behave as a blog, and you don’t need to rewrite your URLs to make it work.

    Thread Starter Elisa

    (@s2_krish)

    Thank you Jessn

    I did you as suggest. However blog doesn’t get blog prefix. Now
    mysite.com/2012/12/celebrating-the-two-glorious-year/. I always want blog to be accessed with blog prefix in url like mysite.com/blog/2012/12/celebrating-the-two-glorious-year/

    Thread Starter Elisa

    (@s2_krish)

    I am posting code here, main thing is ‘with_front’ => false,

    Code snippted

    rewrite' =>
      array (
        'slug' => 'testimonials',
        'with_front' => false,
        'pages' => true,
        'feeds' => 'testimonials',
      ),

    Full plugin code is

    <?php
    /*
    Plugin Name: Hide blog
    Version: 1.0
    Plugin URI: h
    Description: Hide the blog prefix
    Author URI:
    
    */
    
    add_action( 'init', 'register_my_cpt_testimonials', 10 );
    function register_my_cpt_testimonials() {
    register_post_type( "testimonials", array (
      'labels' =>
      array (
        'name' => 'Testimonials',
        'singular_name' => 'Testimonial',
        'add_new' => 'Add New',
        'add_new_item' => 'Add New Testimonial',
        'edit_item' => 'Edit Testimonial',
        'new_item' => 'New Testimonial',
        'view_item' => 'View Testimonial',
        'search_items' => 'Search Testimonials',
        'not_found' => 'No testimonials found',
        'not_found_in_trash' => 'No testimonials found in Trash',
        'parent_item_colon' => 'Parent Testimonial:',
      ),
    
      'rewrite' =>
      array (
        'slug' => 'testimonials',
        'with_front' => false,
        'pages' => true,
        'feeds' => 'testimonials',
      ),
      'has_archive' => 'testimonials',
      'query_var' => 'testimonials',
    ) );
    }

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Customized permalink structure for custom post type and default post type conten’ is closed to new replies.