To add an extra class when there is no title
<h1<?php if(!get_the_title()){echo ' class="no-title"';}?>><?php the_title();?></h1>
Or to only display h1 tags when there is a title
<?php if(get_the_title()) { ?>
<h1><?php the_title();?></h1>
<?php }?>
Related Posts:
- Apply the_title() filter in post & page title, but not in menu title
- Hide add new page button
- How To Keep Posts from Being Displayed Two or More Times on My Homepage? [closed]
- How to style archive post titles… but only those posts who have comments?
- My Custom Post Type Still Using index.php
- Indenting within a blockquote
- Post Category link is same with Page link
- Hide title in Merlin Theme on posts and pages only
- Get post title of faulty link on 404 error page
- CSS – Change height of Storefront / WooCommerce product categories, but not products
- I want the Title of page/post to show up topmost when reading the post/page
- Hide page title on dedicated posts page
- How to make default “Privacy Policy Page” a normal page?
- Loop doesn’t show title of second post and posts thereafter
- How To capitalize The First Letter Of Every Word In The Post Title
- Grid post page on WordPress with Bootstrap, the_excerpt(); Problem
- disable Tab post on nav-menus page (Admin)
- Proper way of establishing custom landing pages in WordPress
- How to show show the Second page title in the page
- Every second post different class in blog view
- How to get links to the last N posts in a specific category?
- is_page Funtion for Posts ?
- is_page() and is_page_template() not being differentiated
- Make a vertical dynamic list of posts in alphabetically order and in columns [closed]
- Create a list of posts with topic headdings
- Admin – no Featured image choice in create new/page|post
- How to detect when admin user is on the All Posts page?
- How to make different custom post layouts?
- static landing page leading to author specific pages w/ “live” content
- Is there any way to stylize articles one by one?
- Blog post not showing title
- Font shows up as Arial instead of Times [closed]
- Total number of posts in query (category/tag/author/search results/main page…)
- How can I remove the first two words and shorten get_the_title()
- Custom Permalink Structure for Pages & Posts
- Getting a “404 Not Found” error when “Preview Changes” is clicked
- Why won’t pagination work?
- How do I include the category next to the title of a post?
- WordPress Query Posts From Category Post on Static Page
- How to create a “latest news” page showing a list of posts from blog category
- How do you search for a post or page with a certain url on the WordPress admin panel?
- How to add some html formated text to every new post in WordPress
- Replace image name on upload to the new post name on front-end form
- Edit the post title from the frontend
- Intercept page request and add value to it
- Why in my query is display two title?
- WordPress 302 Redirect to Random Product/Post/Page
- Output Post with ACF Fields into other Post
- How to create a page that shows the last 10 posts?
- $_GET parametters not working in an specific template
- Image behind the post’s title
- New Posts and Pages Won’t Save
- get_children returns older images
- Change Post Title For Specific Category
- Posts and Pages: 404 Page not found
- the_content() Not Grabbing All Content
- How to remove “» (title of post or page)”?
- Display Featured Posts Grid on Static Page (Gazette)
- Detecting current page from class method
- How can I add a class to particular paragraphs in my post?
- add div after image in post [closed]
- Auto update post title and slug when post status is changed
- Having pages after specifying post_type post
- Unabled to Change Permalinks – Even Using the “Edit” (Resets to Original Permalink on “Update”)
- How do I switch css class on post
- List all posts, pages and custom post types in admin
- Get featured image on hover of post title [closed]
- Make ‘blog’ page show content as well as posts underneath it
- I don’t want the complete article to show on homepage
- Post/page title to permalink transformation – what is behind the scenes?
- Change Author Name to Sitename on Frontend
- Would a “hub” page work better as a page or a post?
- Display on page every post in blog WITH comments
- Are post, page and category IDs unique to each other?
- Microformats in a single post – layout conflict
- Showing recent post of category in page
- HTML Inside of Shortcode Breaks Shortcode Output
- How do I display the post_title with get_permalink?
- Post titles and thumbnails as links to custom post types?
- Setting limit to posts or page creation
- If post exists, make it a comment in existing post with same name?
- Create a frontpage.php and static page template
- Using Posts Like a Page
- Pagination for normal (standard) posts on a page with a custom loop?
- Changing wp_link_pages() to “Next Page” and “Previous Page” buttons?
- posts going to 2 pages/categories only show up in 1
- Have posts included on a page that share same category
- displaying the categories post
- Preview page/post revisions without overwriting current content
- Link from Post to Another Post Via Clicking on Words within Original Post
- How to separate each individual blog post?
- Page of posts made to look like homepage
- post/page content
- Link to older links
- How to link post titles on page A to its posts on page B?
- WordPress Architecture as a CMS – Posts & Pages
- Is it to possible to insert a page in the post depending on the category ofthe post
- Organization of time insensitive content
- Direct some posts to only appear on a specific page
- Adding if statement into the_content()