Home Forums WoodMart support forum Function for page title

Function for page title

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #689698

    metuza
    Participant

    Hello,

    I have modified the below function to show page title on all pages, posts and products but with the latest woodmart update the background image is not loaded so i need to edit my code in comparison with your new code. BUT i can no longer find the below function in woodmart, so can anyone just point me to where i can find the new updated code?

    if ( ! function_exists( 'woodmart_page_title' ) ) {
    	/**
    	 * Page title.
    	 */
    	function woodmart_page_title() {
    		global $wp_query;
    
    		if ( function_exists( 'dokan_is_store_page' ) && dokan_is_store_page() ) {
    			return '';
    		}
    
    		$disable               = false;
    		$page_title            = true;
    		$breadcrumbs           = woodmart_get_opt( 'breadcrumbs' );
    		$style                 = '';
    		$page_for_posts        = get_option( 'page_for_posts' );
    		$page_for_projects     = woodmart_get_portfolio_page_id();
    		$title_class           = ' page-title-';
    		$title_type            = 'default';
    		$title_design          = woodmart_get_opt( 'page-title-design' );
    		$title_size            = woodmart_get_opt( 'page-title-size' );
    		$title_color           = woodmart_get_opt( 'page-title-color' );
    		$shop_title            = woodmart_get_opt( 'shop_title' );
    		$shop_categories       = woodmart_get_opt( 'shop_categories' );
    		$single_post_design    = woodmart_get_opt( 'single_post_design' );
    		$title_tag             = 'h1';
    		$custom_page_title_tag = woodmart_get_opt( 'page_title_tag' );
    		$page_id               = woodmart_page_ID();
    
    		if ( 'default' !== $custom_page_title_tag && $custom_page_title_tag ) {
    			$title_tag = $custom_page_title_tag;
    		}
    
    		if ( 0 !== (int) $page_id ) {
    			$disable = get_post_meta( $page_id, '_woodmart_title_off', true );
    
    			$image = get_post_meta( $page_id, '_woodmart_title_image', true );
    
    			$custom_title_color    = get_post_meta( $page_id, '_woodmart_title_color', true );
    			$custom_title_bg_color = get_post_meta( $page_id, '_woodmart_title_bg_color', true );
    
    			if ( is_array( $image ) && isset( $image['id'] ) ) {
    				$image = wp_get_attachment_image_url( $image['id'], 'full' );
    			}
    
    			if ( $image ) {
    				$style .= 'background-image: url(' . $image . ');';
    			}
    
    			if ( '' !== $custom_title_bg_color ) {
    				$style .= 'background-color: ' . $custom_title_bg_color . ';';
    			}
    
    			if ( '' !== $custom_title_color && 'default' !== $custom_title_color ) {
    				$title_color = $custom_title_color;
    			}
    		}
    
    		if ( 'disable' === $title_design ) {
    			$page_title = false;
    		}
    
    		if ( ! $page_title || ( ! $page_title && ! $breadcrumbs ) ) {
    			$disable = true;
    		}
    
    		if ( is_singular( 'post' ) && 'large_image' === $single_post_design ) {
    			$disable = false;
    		}
    
    		if ( $disable ) {
    			return '';
    		}
    
    		woodmart_enqueue_inline_style( 'page-title' );
    
    		if ( woodmart_woocommerce_installed() ) {
    			woodmart_enqueue_inline_style( 'woo-shop-page-title' );
    
    			if ( woodmart_get_opt( 'shop_categories' ) ) {
    				woodmart_enqueue_inline_style( 'shop-title-categories' );
    				woodmart_enqueue_inline_style( 'woo-categories-loop-nav-mobile-accordion' );
    			}
    		}
    
    		$title_class .= $title_type;
    		$title_class .= ' title-size-' . $title_size;
    		$title_class .= ' title-design-' . $title_design;
    
    		if ( 'large_image' === $single_post_design && is_singular( 'post' ) ) {
    			$title_class .= ' color-scheme-light';
    		} else {
    			$title_class .= ' color-scheme-' . $title_color;
    		}
    
    		do_action( 'woodmart_page_title', $title_class, $style, $title_tag, $breadcrumbs, $page_title );
    
    		if ( 'large_image' === $single_post_design && is_singular( 'post' ) ) {
    			$image_url = get_the_post_thumbnail_url( $page_id );
    			if ( $image_url && ! $style ) {
    				$style .= 'background-image: url(' . $image_url . ');';
    			}
    			$title_class .= ' post-title-large-image';
    
    			?>
    				<div class="wd-page-title page-title<?php echo esc_attr( $title_class ); ?>" style="<?php echo esc_attr( $style ); ?>">
    					<div class="container">
    						<?php if ( get_the_category_list( ', ' ) ) : ?>
    							<div class="meta-post-categories wd-post-cat wd-style-with-bg"><?php echo get_the_category_list( ', ' ); // phpcs:ignore ?></div>
    						<?php endif ?>
    
    						<<?php echo esc_attr( $title_tag ); ?> class="entry-title title"><?php the_title(); ?></<?php echo esc_attr( $title_tag ); ?>>
    
    						<?php do_action( 'woodmart_page_title_after_title' ); ?>
    
    						<div class="entry-meta wd-entry-meta">
    							<?php
    							woodmart_post_meta(
    								array(
    									'author'        => 1,
    									'author_avatar' => 1,
    									'date'          => 1,
    									'comments'      => 1,
    									'author_label'  => 'long',
    								)
    							);
    							?>
    						</div>
    					</div>
    				</div>
    			<?php
    			return '';
    		}

    Brgds
    Rune

    #689728

    Artem Temos
    Keymaster

    Hello,

    This PHP function is still there; you can find it in the file woodmart/inc/template-tags/template-tags.php

    Kind Regards

    #689730

    metuza
    Participant

    Fantastic.. Thank you 🙂

    #689734

    Artem Temos
    Keymaster

    You are always welcome. 🙂

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Function for page title’ is closed to new replies.