If you only need the title you can request it outside the loop easily.
Try and call the_title()
in your header. It should work
But you have to be aware that if you don’t put a condition, each page of your website will display its title in the header section.
EDIT: the function to call is get_the_title($post->ID)
since the_title()
doesn’t allow you to specify the post id as an argument. You can check on the WordPress Codex for function allowing you to query information from your post outside the loop.
Related Posts:
- How to get year, month and hour in WordPress?
- Is sanitize_title_with_dashes formatting function too liberal (in terms of accepted characters)?
- How to set up VS Code for WP plugin/theme development in 2021? [closed]
- trigger html cleanup for all posts
- Customize position of social icons in upme plugin [closed]
- Function sanitize_title() does not appear to be working
- Calling PHP Titles inside Javascript Markup
- Changing Date Format on Custom Meta Data w/shortcode call
- Reformat data within a nested array
- ACF loop and php formatting
- Generating a number based on post ID
- How exactly do automatic updates work?
- How to create custom 401, 403 and 500 error pages?
- Why have on every line
- add_action in namespace not working
- How to add some custom HTML to the edit posts page
- Add Useragent to the body class?
- How can I get an XML export of my 1K+ posts WordPress instance?
- Exclude pages with certain template from wp_list_pages
- How to get Poster (thumbnail) Image of Video
- API response to be stored locally
- PHP code to call image Caption, Alternative Text, and Decription?
- How to rewrite URL with PHP variables with htaccess to a normal looking URL?
- Huge debug.log because of “undefined offset in media.php”
- Can’t get wp_insert_post to work
- Why not yield/iterable in posts interface?
- Part of title duplicating but not sure how to remove from code – help?
- How can I Add a variable PHP in the Menu Nav
- Pull the content out of a page
- PHP Fatal error: Uncaught mysqli_sql_exception: Table doesn’t exist in wordpress/wp-includes/wp-db.php
- Adding an Avatar to the Top Nav Bar
- The response is not a valid JSON response, wordpress problems?
- Firing schema via code in functions.php doesn’t work
- Blog posts repeat
- Dot is not added at the end of href
- Update user profile information from functions.php
- Getting error when using wp_insert_post()
- If tag equals then show else show
- PHP conditional script issue
- WordPress plugin: render only page content using ajax call
- How to fix this warning:call_user_func_array() expects exactly 2 parameters, 1 given in D:\wamp\www\…….\wp-includes\class-wp-hook.php on line 286
- My php code is not being executed
- Using Shortcode to Grab Archive Listing, Separate by Year
- Function won’t run onclick using Ajax
- working with term_relationships table
- Creating a blog on my companies new website using WordPress but I have sidebar issues
- How to show meta value code HTML after x paragraph
- List all blogs, but exclude the main site
- Check class_exists before class definition / Doxygen problem
- How do I create a secondary version of the_content
- url_to_postid returns 0
- How to Fix an Archive.php That Displays All Posts?
- Dynamically replicate custom metabox in custom post type
- random reason on refresh
- How to tell if a user has gone in and created a menu
- Change Query Arguments (filter) with jQuery/Ajax or PHP?
- WordPress Fresh Install Errors (Woocommerce specifically now)
- Tracking Visitor LatLng with WordPress using JS, PHP. How to put data which was extract using JS into DB
- php script in elementor
- WP-Bakery – Add custom colors to buttons with template colors
- how do i add custom widget woocommerce shop page with php
- WordPress redirect to a subpage – how to create a template for subpage?
- How to show 1 random post result without using an array?
- How can I redefine WordPress wp-content directory programmatically?
- Trim Titles Only On Some Pages
- Commenting requires wordpress login, wordpress discussion and post comments tick boxes are checked
- code that I can run, or a plug in to show what sql tables something pulls information from
- Automatic email message after manual user approval
- can I extend the WP_Query class to deal with ‘duplicate’ posts created by joining to wp_posts?
- Enqueue sripts and styles only if function is called
- Return author name as a tag using get_author
- How to pull date/time in french format for wordpress post?
- WooCommerce subcategories help
- What is wrong with this shortcode? to include external php file in WordPress posts
- Echo Option Value Based On WordPress User Role
- Crop an image after upload on custom account page
- Migrating a live WordPress website to a Local Server: why some elements of the website are missing?
- Store stripe info as user_meta
- Is there a way to have chunks of a page’s content expire?
- Loop returns more items than exist?
- Formatting Shortcode to Display in Visual Mode
- wp_nav_menu doesn’t work in a duplicate server
- Rewriting to a different page based on existence of query string?
- How to get category pages to look like a certain archive page?
- Host does not allow remote connection, so how do I transfer data to my WordPress site?
- I am extending Walker_Nav_Menu: How can I get the number of children elements of the current item?
- How to call a specific value within the functions.php file?
- How to define template directory in this widget code
- WordPress plugin/code to to to next/previous post in same category
- WordPress White Screen Error
- Keep users logged in Without Remember Me
- How to use js variable to php in wordpress functions.php
- Display total count of products in orders of a specific order status
- There’s a 0 adding to the value on multiple post type
- Add/alter image attribute before render
- How do I do so that people can register on my wordpress site?
- footer doesn’t display
- hiddenQuestions.find is not a function
- How can I improve and optimise my wordpress web server for better performance in 2023
- Internal server error when enabling Multisite in WordPress