Your shortcode is getting the title, but you haven’t told it to return anything, so a small tweak should fix things:
<?php
function post_title_shortcode(){
return get_the_title();
}
add_shortcode('post_title','post_title_shortcode');
?>
You could also continue setting get_the_title()
to $variable
and add a line to return $variable
, but the above is the simplest, shortest option.
Related Posts:
- Newbie question: no index.php? in my plain wordpress permalink
- Missing sidebar parameter “fix” – before_content
- How to change redirection route to a php page for making it only accessible by logged-in members?
- parts of url disappear when using # inside href=”” [closed]
- Create custom permalinks to show Custom Post Type’s relationship?
- Add .htm extention to a custom taxonomy
- Show latest posts in a plain HTML website custom widget [closed]
- Widget back end radio button issue
- How do i add slugs to a URL, but still redirecting to the same page
- Nginx WordPress and another Web app URL structure
- How to use title attributes in sidebar widget?
- Modifying WP URL handing code?
- How to deal with a GET variable of ‘name’?
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- Add Link to PHP message
- How does one make a URL return dynamic JSON with custom Content Type?
- Why does WordPress remove my variables in the URL?
- How Display Posts on category
- How to rewrite URL with PHP variables with htaccess to a normal looking URL?
- How to get the POST TITLE using the POST ID?
- HTML tags in bloginfo description
- ACF page while loop breaks footer while loop
- How to add just one specific page to widget without plugin?
- Getting a specific post values to another div or modal
- Static variable and add_rewrite_rule?
- Add a class to the anchor tag on HTML5 gallery
- Transferring working local PHP site to wordpress – with database (MySQL)
- Nesting if statements to echo only one string based on what tag was filtered?
- Create onClick Event to Re-load a Widget
- How to put a variable in a instance in the widget
- how to remove metadata from the posts of my blog?
- How to output widget
- Load a page into a div with Ajax
- My form action url is being prepended with a directory that does not exists
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- Converting HTML Template to WordPress Theme
- Extending the WP_Widget_Text class
- How to change home or site url using action hooks or filter?
- Multiple options not staying selected after saving
- Why do WordPress rewriites seem to work differently for posts vs pages?
- Performance impact of rewriting WordPress URLs
- Using the echo command adds unwanted br tags to source
- Dynamic Sidebars & Echo
- custom fields wordpress
- Why the JavaScript code is ignored from wp editor?
- Is sanitize_title_with_dashes formatting function too liberal (in terms of accepted characters)?
- Populate dropdown with Child Pages based on Parent Page chosen
- How to store data from multiple forms using ajax and php
- search and replace preword from author
- Embed html in php code
- WP grandchild categories in nested ul li
- Use DOMDocument with ob_start breaks my HTML code
- Dynamic content based on a URL parameter
- WordPress Shortcodes.. printf is outputting a random number… Can’t figure out WHY?
- Colon is Missing In My Website Url in WordPress
- Changes in permalink structure in WordPress and how to apply to in-site links
- WordPress Persistent connection rule does not work for “posts”
- How to use $_GET function WordPress backend
- Append query string to all URL’s
- How to make my custom widget appear within WordPress widgets? Plugin development
- get widget number from array dynamically
- custom rewrite rule help! Custom rewrite rules not applying to custom post type
- selected option if current category is the value
- Adding widgets to my plugin page instead of WordPress dashboard
- subdirectory index.php is not working
- Use URL Rewrite as well as $_GET parameters in URL?
- How to modify URL (add GET values) after front end form submission?
- How to remove ?wp-mce-4103-20162941
- Customize position of social icons in upme plugin [closed]
- Why Won’t My Inputs in a form with a Get method work together?
- Extend PHP regex to cover “srcset” and “style” attributes
- Hide subcategories (widget)
- Settings API callback function inserts html quotes from nowhere
- Input data from email form not going to JSON file
- How to get the value of input hidden html from text editor to custom page template?
- Why my image upload button is not working in wordpress widget area?
- Different post styles depending on category
- How create a Shortcode with hover and complex options
- How do I remove the product thumbnail link from a specific div in Woocommerce? [closed]
- My php header() function is not working [closed]
- Dot is not added at the end of href
- WordPress Multiple Navigation bars
- Position banner to right of logo in header – messed up my header file
- Adding a widget function into the php theme file
- Commenting out unwated CSS/scripts in HTML with PHP
- How to edit widget code to add unique class name to each div?
- Scrape external webpage for first image and add it to new post
- How to separate HTML and WordPress files
- Search Query: how to construct a search string from two select elements?
- Login to wordpress by clicking a link and specifying usernaname and password in url
- Help with .htaccess and Login with Subfolders
- Get URL Parameters from referer
- Need help enqueueing webfonts
- Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )
- If has $title in widgets
- How do I add a custom css to all posts without affecting homepage css? [closed]
- Archives shortcode displaying above widget title
- Make PHP work with HTML tags
- Widgets in the loop if active
- WordPress add_rewrite_rules for custom URLs ending in .html