aha…white screen of death. I don’t know how I missed it. Your if
statement lacks parenthesis.
Try this:
public function title() {
if ( is_category() ) {
echo '<h2 class="post_title">';
} else {
echo '<h1 class="post_title">';
};
echo '<a href="';
the_permalink();
echo '" data-disqus-identifier="';
the_ID();
echo '">';
the_title();
if ( is_category() ) {
echo '</a></h2>';
} else {
echo '</a></h1>';
};
}
stackexchange needs syntax highlighting 🙂
Related Posts:
- Use template for posts with a particular category grandparent
- Inject post (from specific category) between posts in Loop
- exclude multiple terms using get_terms() function
- Counting number of posts in a category and its sub categories and displaying result using shortcode
- Allow authors to post only in categories they create in WordPress
- Add custom field to attachments in a specific category
- How to Populate the list of custom post type categories
- Php string not working in WordPress Functions.php [duplicate]
- Looking to exclude blog posts from category Previous/Next buttons
- How to display related posts from parent category
- Disable External Pingacks on WordPress Posts and Only Allow ‘Self Pings’
- New Plugin Review
- Problems with function on function.php
- Check if Product is in a Specific Category in Functions.php
- Woocommerce – remove product from category
- Query all posts of a custom taxonomy term
- get current product name in functions.php
- get post based on category chosen in drop down – The ajax method
- Swapping wp_dropdown_categories function with wp_category_checklist
- Get post id in a function when edit/add a post
- how do I get a specific post from a post with a subcategory in WP
- Pass Category Name, Description and Photo into variables to pass to jQuery
- wp_trim_words() does not work with my code Am I doing any mistake in my code?
- How to pick the default selected value in wordpress dropdown?
- Get page that displays all children of taxonomy parent
- How to show only subcategories in parent category not parent category?
- Redirect to another page using contact form 7? [closed]
- Dilemma of Populating all the categories in a drop down list
- Which PHP page is the Default Posts Page
- Edit the_category (); for a hierarchical display
- Function works everywhere, how to keep it to execute when creating a new post
- Pagination on Custom Post
- Get latest post from all categories except one
- Displaying posts based on category
- How to get current post category details inside “loop”?
- How to use mysql LIKE with wpdb?
- Reading settings in the home page precisely home.php
- Show all tags within a category?
- Post not populating for custom post type based on category selection
- Add new post in existing categories using wp_insert_post
- get post id from wp_insert_post for get_template_part
- Displaying list of posts in category page
- Do not duplicate posts with multiple categories in multiple loops
- Loading Posts & Category with Ajax
- remove specificly the last tag in all posts
- Pagination at category doesnt work with same name of page
- How to show categories and date on posts
- What is the best way to set the post category (Custom Post Type) automatically based on the one of the tags assigned to the post?
- Dropdown category field inside repeatable metabox
- How to Send Pingbacks for all Posts in WordPress?
- Display Visual Composer shortcode if a post belongs in specific categories
- posts_per_page displays only 2 posts instead of 4 posts
- Get parent category name when only child category is applied to a product
- How to move a post from one category to another
- Trying to show the category of a post in the post display
- Notice: Undefined variable
- Hide a specific category title from displaying on site
- Send POST request to Flask app from functions.php file
- How to center all text body in single.php at once?
- Populate Posts based on category selected using AJAX that means without page refresh
- All categories options or All categories not Populating
- Getting page / post URL on publish and / or update
- Customizing the output of the archive and category widget without altering the original behavior of the widget
- Displaying POST content with HTML tags and all
- Displaying 3 Category Posts differently
- PHP get_category() function redeclared
- Using Tag Groups: Displaying groups and adjacent tags of current post
- How do I get the featured post to share on Social Media and show on Individual Post pages?
- Unable to get Post Category Name and URL
- insert thumbnail image from php script
- Can’t put a hyperlink on Featured Post’s Image
- Weird Behaviour: Not all WordPress Posts appearing
- Published custom posts missing
- WordPress get_post_meta issue
- Get category id for a custom category and display it in a class
- Insert wordpress tags below posts via functions.php
- Display post of specific category on page
- Displaying categories
- How to modify this function to exclude also the post belonging to a specific category?
- How to display the date under the post title?
- How to insert the first letter in uppercase [closed]
- Add multiple HTML attributes to an Elementor button
- Hide child of parent categories already hidden with “get_terms_args” – Woocommerce
- WooCommerce: write featured image dimensions to custom fields in product’
- How do I get a function to work in single.php
- transition_post_status hook, works – but not if the post is new
- Exclude a category ID from the following function
- How to get year, month and hour in WordPress?
- Calling a method from functions.php on a click of a button
- How do I create comment-reply-button using element not
- Making Quote Plugin more efficient
- How can I get the values of my WordPress $wpdb query in Jquery?
- Adding wrapper elements in the_date() like in the_title()?
- PHP code for displaying WordPress posts in a static page not working
- Post to WordPress from another Server via PHP
- Child Theme’s Read More Text
- call a string/function from database
- Highlight Single Page Ancestor
- Removing get_template_part in child theme
- dynamically filter by category via sub-menu