WordPress.org

Ready to get started?Download WordPress

Forums

post_types_archives :( what for ? (8 posts)

  1. sergeletko
    Member
    Posted 3 years ago #

    Hi to every one,

    just a question why changing wp_query by post type from is_home to is_archive ? especially when there's no term set in this "archive" query ?

    for me personnaly it looks like mixing the destiction of custom post type and a custom taxonomy ..... ;(

    for those who get 404 on "index" pages for custom post type -> try to follow the logic in your permalinks like this :

    video/video-post/ a single

    videos/ is the famous post type index page ...

    works perfectly on any wp installation ,just use is page('videos') -> wp_reset_query() , + normal home query but with post_type set to needed...

    then is_home() works perfectly on any "index" page of any custom or build_in post type

    in 3.1 you'll have to reinvent the weel to get that stuff working easily

  2. sergeletko
    Member
    Posted 3 years ago #

    just a small word why inventing is_post_type_archive($args) instead of redesigning is_home($arg) that would drasticaly simplify and unify post_type management

    like

    is_archive() {
    //this logical tree will inspect taxonomies
    //so les't get the term_id
    global $wp_query;
    $term_id = $wp_query->queried_object->term_id;
    } elseif is_home() {
    if(is_home('post')) {
    //this is your home page for blog
    }elseif (is_home(array('services','products'))){
    //this is one of home pages for the stuff you sell..
    }
    }
    easy isn't it
    now try to repeat that with your "new" archive api

  3. sergeletko
    Member
    Posted 3 years ago #

    for the 404 pages you could simply add a supplementary parameter to rewrite rule as index_rewrite_slug for custom post registration, so that would reserve the slug for extended home pages

  4. sergeletko
    Member
    Posted 3 years ago #

    sorry this one :

    }elseif (is_home(array('services','products'))){

    should be :

    }elseif (is_home(array('service','product'))){

    to avoid 404

    easy?

  5. sergeletko
    Member
    Posted 3 years ago #

    sorry getting mad, i'm just a simple barman, who didn't know php exists 2 yaers ago, now i'm creating premium plugins for my customers under thesis theme(the real framework ) and i see i will have doubled my job to get the results i had before 3.1 wp for is the guy i work with to pay my bills

  6. sergeletko - Please be patient. The vast majority of the people who held here are unpaid volunteers. Posting over and over and getting mad doesn't make us work faster.

    just a question why changing wp_query by post type from is_home to is_archive ? especially when there's no term set in this "archive" query ?

    Because it IS an archive. What are you actually trying to do? Make an archive page for Custom Post Types?

  7. sergeletko
    Member
    Posted 3 years ago #

    Hi, Ipstenu , kind of you to answer .
    Here's my logic
    post is a post type and the index page for post post type is_home()
    now i have a product sold on a website under wp , i register it as a custom post type, i call it product instead of post , so following same trame -> index page for all products is_home() as well , but with a different post type ( is_home('product') ) ...

    and here is wp 3.1

    home is index for posts but archive is the index for products.

    so next type i'm trying to get taxonomy term or asking if it is an archive i'll have to do it like this :

    if(is_archive() && !_is_post_type_archive()) or to detect post type i'll have to do

    if(is_home() || is_post_type_archive()) that's what i call bloated code...

    Both home() and archive() are idex pages but home uses post_type as criteria and archive is using taxonomy termas as criteria , that was a simple difference to understand, now it is gone with is_post_type_archive...

    for me it is like making complicated instead of simplifying.

  8. sergeletko
    Member
    Posted 3 years ago #

    before i used different classes called to construct index pages for different post types, they were triggered by is_home() (i'm not using ancient template system but dynamic template construction )

    now is is a mess , so when wp will try to use this flexible kind of templates later ( 4.0 eg ) you'll be havig same issues...

    eg i used post_thumbnails before wp 2.6
    eg i'm using term_icons without a plugin now, you'll be using them when ?

Topic Closed

This topic has been closed to new replies.

About this Topic