• Resolved platingpixels

    (@platingpixels)


    I’d like add my Blog Subheading to all pages and posts, not just the homepage. I added it under theme options > site description, but it only shows on the home page. Is there a setting or do I need to change or add code somewhere in the theme file?

    If people land on my site on another page I want them to see that tagline (especially since the sidebar and about info is hidden on mobile with this theme). Love them theme and thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi platingpixels. Is this on your https://www.platingpixels.com/ site? If so it’s because the site description font color is set to white. Change the color and it should show up:

    .site-description {
      color: #000;
    }
    Thread Starter platingpixels

    (@platingpixels)

    That is my site and I tried adding that code to my css editor. It didn’t do anything. What’s weird is you see it on the homepage in gray “A Recipe Resource to Teach You About Cooking” But doesn’t show in any other post or page. How do I fix that? Thanks!

    The css you added makes the site description (tagline) visible to the right of the site title in the heading. Previously it was “hidden” because it was the same color as the background.

    I added it under theme options > site description,

    This threw me off for a bit as there is no place to enter the site description in the theme options. The Theme Options > Blog > Heading and Subheading are displayed in the page title container on only the home page. Other pages inherit the page title from the page name or type (i.e. Category) and the group (i.e. Snacks). In addition, each defined page can have an individual Heading and Subheading.

    To display the Blog Subheading on every page you could copy header.php to a child theme, then add a container that is populated by calling function alx_blog_title(), then position and style it using css. Or, if you wanted to put it where the page title is, you could copy function alx_blog_title() to a child theme functions.php file, then rename it to alx_page_title(). That would override the alx_page_title() function in the parent theme. That’s just off the top of my head; there are probably other ways to approach it.

    Thread Starter platingpixels

    (@platingpixels)

    Sorry but I tried to make sense of what you suggested did a few options based on that, and it locked up my site. I was able to revert back easily. I have this code in my function that sounds like what you are referring to. How exactly should I change it to get my blog subheading to show on all post? (it’s in the are right to the left of the comment count on posts – you can see it on my homepage but not posts.

    Page title
    /* ------------------------------------ */
    if ( ! function_exists( 'alx_page_title' ) ) {
    
    	function alx_page_title() {
    		global $post;
    
    		$heading = get_post_meta($post->ID,'_heading',true);
    		$subheading = get_post_meta($post->ID,'_subheading',true);
    		$title = $heading?$heading:the_title();
    		if($subheading) {
    			$title = $title.' <span>'.$subheading.'</span>';
    		}
    
    		return $title;
    	}
    
    }
    
    /*  Blog title
    /* ------------------------------------ */
    if ( ! function_exists( 'alx_blog_title' ) ) {
    
    	function alx_blog_title() {
    		global $post;
    		$heading = ot_get_option('blog-heading');
    		$subheading = ot_get_option('blog-subheading');
    		if($heading) {
    			$title = $heading;
    		} else {
    			$title = get_bloginfo('name');
    		}
    		if($subheading) {
    			$title = $title.' <span>'.$subheading.'</span>';
    		}
    
    		return $title;
    	}
    
    }

    Since the single post uses a different process to generate the page title I would take those two functions out of your child theme; they’re not needed.
    Copy the /inc/page-title.php file to your child theme. Make sure to put it in the same /inc subfolder in the child theme. At the top of the file you’ll see this:

    <?php if ( is_home() ) : ?>
    	<h2><?php echo alx_blog_title(); ?></h2>
    
    <?php elseif ( is_single() ): ?>
    	<ul class="meta-single group">
    		<li class="category"><?php the_category(' <span>/</span> '); ?></li>
    		<?php if ( comments_open() && ( ot_get_option( 'comment-count' ) != 'off' ) ): ?>
    		<li class="comments"><a href="<?php comments_link(); ?>"><i class="fa fa-comments-o"></i><?php comments_number( '0', '1', '%' ); ?></a></li>
    		<?php endif; ?>
    	</ul>
    
    <?php elseif ( is_page() ): ?>
    	<h2><?php echo alx_page_title(); ?></h2>

    Change the is_single() block to be the same as the is_home() block so it looks like this:

    <?php elseif ( is_single() ): ?>
    	<h2><?php echo alx_blog_title(); ?></h2>

    If you want to override the page title on all pages as well, you would make the same change to the is_page() block.

    Thread Starter platingpixels

    (@platingpixels)

    That did it. Thank you so much!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How do I add Blog Subheading to all pages/posts’ is closed to new replies.