Custom displaying post tiltle instead of taxonomy name

VWSとは フォーラム Lightning Custom displaying post tiltle instead of taxonomy name

Custom displaying post tiltle instead of taxonomy name

3件の投稿を表示中 - 1 - 3件目 (全3件中)
  • 投稿者
    投稿
  • #23713

    syouei-branding
    参加者

    Hello,

    A taxonomy name is displayed as a header title in a post now, but I would like to show a post title instead of showing taxonomy name.
    I rewrote a litle bit of code in module_pageTit.php file and added the file to the child theme.
    It worked perfect in case of post, but it duplicated the page title in case of page type. I don’t know why, because I only rewote in the “is_single() if statement”

    if ( is_single() ) {
    				$taxonomies = get_the_taxonomies();
    				if ( $taxonomies ) {
    					$pageTitle = get_the_title();
    					/* $taxonomy   = key( $taxonomies );
    					$taxo_cates = get_the_terms( get_the_ID(), $taxonomy );
    					$pageTitle  = esc_html( $taxo_cates[0]->name ); */
    				} else {
    					// Case of no category
    					$pageTitle = $postType['name'];
    				}
    

    Please help me this case!
    Thanks in advance!

    Attachments:
    You must be logged in to view attached files.
    #23820

    1. If you are using the below files in child theme directory, please delete it.

    module_pageTit.php
    template-parts/page-header.php

    2. write to below code to functions.php on child theme.

    add_filter(
    	'lightning_pageTitCustom', function( $title ) {
    		if ( is_single() ) {
    			$title = get_the_title();
    		}
    		return $title;
    	}
    );
    #23830

    syouei-branding
    参加者

    Thank you for your supporting, I resolved it.

    May be I have misunderstood the rule to customize the child theme. If I want to customize or add some html code to the existed file, for example, change the id element of front-page, could I rewrite it and add front-page.php to child theme directory?

3件の投稿を表示中 - 1 - 3件目 (全3件中)
  • このトピックに返信するにはログインが必要です。