Some of the calls in your function will echo rather than return.
Instead of the_author_meta, use get_the_author_meta.
Instead of the_excerpt, use get_the_excerpt.
And use jycr753’s approach; return the whole string rather than echo it.
Related Posts:
- How to check if a theme is active?
- Are there procedures to prevent malicious plugin updates?
- When would it make sense to use Jetpack?
- How do I force wp_enqueue_scripts to load at the END of ?
- Avoiding plugin name collisions with WP updater
- Auto-post to multiple sites like Posterous? [closed]
- WordPress error – PHP Fatal error: Uncaught Error: Call to undefined function register_block_type_from_metadata()
- Can WordPress handle these functionalities?
- How to move the code injected by a plugin below the default WordPress code? [closed]
- How to get popular post from across a network?
- How can I create a simple interface for my WP plugin?
- how to include a simple jquery file into a wordpress plugin
- Where does WordPress register default scripts like jQuery?
- How to get subscription key or id using Woocommerce Subscriptions [closed]
- Rewrite url without flushing the database?
- How to get member list based on role by using buddypress?
- Are there hooks for WordPress updates?
- Determine Registered Admin Menus
- Removing plugin settings from database
- Add stylesheets and js to template files when shortcode is used
- Which plugin will let me decide what users have access to on their side bar in wp-admin?
- How to create user groups and allow custom posts and plugin modify/access to specific group?
- How can I disable the multisite feature of WordPress 3.0?
- How to translate __(”) strings in admin [closed]
- Breadcrumb NavXT plugin – exclude ‘home’ page
- WordPress comments not appearing in blog posts, likely because of Redux template. Could I fix this with a plugin that adds a comment form as a block? [closed]
- trying to get user info in plugin
- How to delete page by deactivating plugin
- Customize permalink wordpress category id
- Take input from form and pass it to function using a wp-plugin
- Translation for the plugin using redux framework does not work
- Re use the list table for a custom post type on another page
- Can we have an ‘Update metadata’ button in Image Gallery for all image instances?
- Stop Plugin Enumeration [closed]
- Change get_current_user_id code to the author’s profile
- Is there a premium plugin for appointment reservation? [closed]
- wp e-commerce sort by stock [closed]
- get_option error plugin development
- How to get the permanent link in a plugin?
- do add_action on condition
- Duplicate results are displayed in a custom plugin [closed]
- Need a wordpress plugin to show tutorial difficulty [closed]
- Plugin is a widget, but I want to call it in the head, can I?
- Meta Box by Rilwis, Load metabox on all page templates EXCEPT the homepage
- Adding rel=”nofollow” to external links in posts?
- Plugin that provides the [edit] shortcode?
- How do I get the Twitter Tools widget to display my tweets?
- Is there a way to convert shortcodes to html content?
- Loop in elementor custom widget not working
- Change text string in a plugin
- How to include files relative to a file’s directory
- track all external links on blog via username
- How to access OOP plugin function inside themes or other plugin
- Contact Form 7 “non-selectable” options in a drop down [closed]
- How to add custom text editor in add post section?
- Anyone know of a plugin for WordPress that uses osCommerce? [closed]
- Minimalistic schedular
- Is it possible/advisable to set last stable version to previous version?
- Rename existing cpt and taxonomy with new textdomain
- FacetWP breaks jQuery events
- Getting infinite scrolling working on my custom template
- Filter Content on Ultimate Membership plugin based on the Country Field Form
- How do I display PHP file contents on front end of WordPress?
- How to apply to hide TinyMCE (wp_editor) on button click
- Plugins custom table not being created on activation
- Facing Problem with admin-ajax.php URL – Getting 404 with AJAX call
- How to overwrite a plugin?
- jQuery Ajax not loading page with ACF fields
- How can I translate something in my class constructor of my plugin in WordPress?
- Which post/page an image is attached to
- Theme that includes a “core” plugin but the files in theme and child folder ignored
- Use buddypress function outside of plugin
- Woocommerce Attribute price for non-variations
- My wp database has been hacked
- No result after wpdb->insert
- How can I disable access to plugin settings in wp admin for other roles
- Searchable Semi Random Number Generator on User Profiles
- Fetching users data from REST API
- Automatically check “Enable stock management at product level” to the existing products?
- Save Post Permalink In .txt File
- Renamed plugin folder and when I changed back nothing was activated
- Tortoise SVN showing ‘Access to ‘/!svn/me” forbidden error.
- Customize CSS for “Swipebox ” lightbox
- Best use adding user generated JS/CSS to a theme with a plugin
- How to create an uploads subfolder on a multisite setup?
- Plugin program: JQuery not working in this plugin
- Slick Social Share Buttons plug-ins with Responsive theme – number of tweets link problem
- How to submit the custom form data in database in WordPress without plugin?
- Managing users / external login
- Jquery UI implementation [closed]
- Windows 10 Printer that Sends to WordPress [closed]
- Why haven’t I see plugins using get_file_data to handle retrieving plugin version?
- How to disable plugin capability : “create new category”
- Scripts don’t enqueue after removing plugin
- Plugins menu not on dashboard
- How to create a “Most Popular” & “Latest” TAB in WordPress
- Multilingual WordPress Website with multiple source languages
- WordPress Multisite Plugin Activation Issue
- Need a WordPress license manager plugin
- is possible to edit diagrams inside wordpress