Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have found solution, or it's kinda workaround, for some reason custom post type archive doesn't work same way as default archive.</p> <p>So for workaround main problem is with permalinks, so i had to use different custom post type name and custom page template.</p> <p>In my functions.php file i have code where i register custom post type called galleries. But since i wanted to use galleries to list all posts i will name my page like that and i had to add rewrite rule to my custom post type so function that register my custom post type now looks like this.</p> <pre><code>function my_custom_post_product() { $labels = array( 'menu_name' =&gt; 'Galleries', 'all_items' =&gt; __( 'All Posts' ), ); $args = array( 'labels' =&gt; $labels, 'description' =&gt; 'Add image galleries custom posts', 'public' =&gt; true, 'exclude_from_search' =&gt; true, 'show_in_nav_menus' =&gt; true, 'show_in_menu' =&gt; true, 'capability_type' =&gt; 'post', 'menu_position' =&gt; 5, 'supports' =&gt; array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments', 'custom-fields' ), 'has_archive' =&gt; true, 'rewrite' =&gt; array('slug' =&gt; 'gallery'), '_builtin' =&gt; false ); register_post_type( 'galleries', $args ); } add_action( 'init', 'my_custom_post_product' ); </code></pre> <p>So instead of galleries my custom post now use gallery slug.</p> <p>Now to list all posts in my gallery i have used code from archive-galleries.php page and created new page template called page-galleries.php and added code from archive-galleries.php.</p> <p>Now i just created new page, selected my newly created galleries template and saved page. Added new page to menu and it works.</p> <p>There is big debate on internet how to make pagination work for custom post type and for some reason it not works as regular archive works, even if it's intended to work native with archive-custom_post_type_slug.php this is only working workaround i have crafted by my self and main problem is which many on internet overlooked (like i did also) is that you can't name page same as post type slug, and archive won't work with permalinks default set.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload