Home › Forums › WoodMart support forum › Issue with create_post_type
Issue with create_post_type
- This topic has 3 replies, 2 voices, and was last updated 4 years, 1 month ago by Artem Temos.
-
AuthorPosts
-
November 6, 2020 at 3:50 pm #239518
dima9891ParticipantI added simple post type in functions.php in child theme.
Overall everything works great, but page title on this pages specifically doesn’t display. I mean title in the top of the page, just under the header. It displays everywhere else on the site, on every other page.Standard blog page (with title) – http://www.flora-center.ru/news/
Custom page (no title) – http://www.flora-center.ru/poleznyie-stati/here is the code I added:
add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'poleznyie-stati', array( 'labels' => array( 'name' => __( 'Статьи' ), 'singular_name' => __( 'Статья' ), 'has_archive' => true, 'add_new' => 'Добавить статью', 'not_found' => 'Ничего не найдено', 'not_found_in_trash' => 'В корзине статей не найдено' ), 'public' => true, 'has_archive' => true, 'menu_position' => 5, 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'post-formats' ), 'taxonomies' => array('category') )); }
November 7, 2020 at 1:44 pm #239735
Artem TemosKeymasterHello,
You can add it with additional code customization only. Edit the file
woodmart/inc/template-tags.php
and replace the following lineif ( is_singular( 'page' ) && ( ! $page_for_posts || ! is_page( $page_for_posts ) ) ) :
with this one
if ( is_singular( 'page' ) && ( ! $page_for_posts || ! is_page( $page_for_posts ) ) || is_post_type_archive( 'poleznyie-stati' ) || is_singular( 'poleznyie-stati' ) ) :
also, add the following snippet https://prnt.sc/vf5be1
if ( is_post_type_archive( 'poleznyie-stati' ) ) { $title = 'Статьи'; }
Regards
November 7, 2020 at 3:07 pm #239746
dima9891ParticipantThank you! that was usefull.
I’ll just mention that if you don’t want to modify main theme files (to keep updates) – you should copy all page title function fromwoodmart/inc/template-tags.php
towoodmart-child/funtions.php
November 8, 2020 at 2:32 pm #239903
Artem TemosKeymasterYes, you can copy the whole function to the child theme to prevent loosing changes with future updates.
-
AuthorPosts
- You must be logged in to create new topics. Login / Register