Forum Replies Created

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter Alan Niemies

    (@alanniemies)

    Hello, Tobias.

    I found it strange, too, as I recall testing these a few weeks ago, still using TablePress, without all this huge time.

    I’m going to try it again. I don’t think ‘m using JavaScript or maybe in one or another post and this is not essential, so I’m going to remove it from loading.

    Thanks a lot!

    Sincerely,
    Alan

    Thread Starter Alan Niemies

    (@alanniemies)

    Maybe I need to create a rewrite URL along with these pieces of code?

    This is what Milo added as a comment in a similar Stack Exchange post (http://wordpress.stackexchange.com/questions/83531/custom-post-type-404s-with-rewriting-even-after-resetting-permalinks):

    “Filtering ‘post_type_link’ is simply changing the URLs WordPress generates when it outputs a permalink for your post type. When you visit one of those URLs, WordPress doesn’t know what to do with them or what they’re supposed to point to, as you haven’t done anything to generate rewrite rules for incoming requests. Without knowing what format you want for your links, it’s not possible to give an answer beyond pointing you to add_rewrite_rule and add_rewrite_tag.”

    Thread Starter Alan Niemies

    (@alanniemies)

    Hi @bcworkz. Thanks for these information.

    As I’m stepping into unknown territory, it’s being hard to understand pre_get_posts.

    Right now, I am willing to simplify these conditional tags as much as possible as I am not using Posts in my website anymore and shouldn’t be using for a long time.

    All I need are pages to work when they are queried for. And for the Custom Post Type “artigos”, I need them to show within category/tag pages as well as in single for this CPT, with the correct slug.

    With this setup, I THINK it would even be possible to modify the main query as well? Does this makes sense or help you guys to help me?

    Anyway, I’m still trying multiple inputs and if I get something, I will update you.

    Thanks again for your help!

    Thread Starter Alan Niemies

    (@alanniemies)

    An update: both the child and parent page page are now working with the /artigos slug or without it:

    – mysite.com/parent-page/
    – mysite.com/artigos/parent-page/
    – mysite.com/artigos/parent-page/child-page
    – mysite.com/child-page

    All working, except the desired config: mysite.com/parent-page/child-page, which still returns a 404

    Strange, right?

    • This reply was modified 9 years, 7 months ago by Alan Niemies.
    • This reply was modified 9 years, 7 months ago by Alan Niemies.
    Thread Starter Alan Niemies

    (@alanniemies)

    Hello @wppatrickk

    Thanks for the above input. I still can’t manage to make it work. I keep getting the 404 in child page. 🙁

    Full code is now this:

    /* Add custom_post_type Artigos */
    add_action( 'init', 'create_artigos_post_type' );
    function create_artigos_post_type() {
      register_post_type( 'artigos',
        array(
          'labels' => array(
            'name' => __( 'Artigos' ),
            'singular_name' => __( 'Artigo' ),
    		'add_new' => __( 'Adicionar novo' ),
    		'add_new_item' => __( 'Adicionar novo Artigo '),
    		'new_item' => __( 'Novo Artigo' ),
    		'edit_item' => __( 'Editar Artigo' ),
    		'view_item' => __( 'Ver Artigo' ),
    		'all_items' => __( 'Todos os Artigos' ),
    		'search_items' => __( 'Pesquisar Artigos' ),
    		'parent_item_colon' => __( 'Artigo pai' ),
    		'not_found' => __( 'Nenhum Artigo encontrado' ),
    		'not_found_in_trash' => __( 'Nenhum Artigo encontrado na lixeira' ),
    		),
          'public' => true,
          'has_archive' => true,
    	  'hierarchical' => true,
    	  'menu_position' => '5',
    	  'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'comments', 'custom-fields', 'revisions', 'page-attributes' ),
    	  'taxonomies' => array( 'category', 'post_tag'),
    	  'capability_type' => 'post',
    	  'with_front' => false,
        )
      );
    }
    
    /* Remove Slug from custom_post_type Artigos */
    function na_remove_slug( $post_link, $post, $leavename ) {
    
        if ( 'artigos' != $post->post_type || 'publish' != $post->post_status ) {
            return $post_link;
        }
    
        $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
    
        return $post_link;
    }
    add_filter( 'post_type_link', 'na_remove_slug', 10, 3 );
    
    function na_parse_request( $query ) {
    
        if ( ! $query->is_main_query() || 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) {
            return;
        }
    
        if ( ! empty( $query->query['name'] ) ) {
            $query->set( 'post_type', array( 'post', 'artigos', 'page' ) );
        }
    }
    add_action( 'pre_get_posts', 'na_parse_request' );
    Thread Starter Alan Niemies

    (@alanniemies)

    @bcworkz,

    Thanks a lot for your resourceful input! I ended up creating the new Custom Post Type and moving all my posts to it, as you stated at the end of your answer, as I think this is better than trying to change a core post type.

    All the transition was seamless. After creating my custom post type I used Convert Post Types plugin to move all the posts to there. Had to change some details in my custom queries in homepage but now everything is working as expected, with the added hierarchical capability.

    Thanks a lot again for your invaluable help! You’re awesome. 🙂

    I’m having the same problem when I tried to activate the plugin after some sensitive changes in my template files.

    Thread Starter Alan Niemies

    (@alanniemies)

    Hello, Jeff.

    Thanks for the reply. I can’t edit this page as it isn’t in the list of pages under WP Admin. So, how can I see/change this meta value?

    Thanks for your time.

    Thread Starter Alan Niemies

    (@alanniemies)

    Any insights on this subject?

    How did you solve the problem, brave73? I’m having the same issue here, using BuddyPress with a /register page for Registration.
    Thanks.

    Hello, xinak.

    I don’t know if you still need this, but I was getting this error on a client’s website and managed to correct it. For me, the issue was with a cache plugin (W3 Total Cache). You have to disable login and other pages from caching.

    For W3 Total Cache, go to Performance > Page Cache. Find the section called “Never cache the following pages:” and add these entries, one per line:

    /login/
    /register/
    /transactions/
    /payments/
    /download/
    /lostpassword/
    /subscribe/

    That should make Magic Members compatible to your website. Hope it helps you or future users. 🙂

    Thread Starter Alan Niemies

    (@alanniemies)

    The page for publishing new articles is in http://medsimples.com/publicar/. If you manage to registrate with Facebook you may take a look.

Viewing 12 replies - 1 through 12 (of 12 total)