Try get_queried_object()
to reference the WP_Post
that created the page.
- if you’re on a single post, it will return the post object
- if you’re on a page, it will return the page object
- if you’re on an archive page, it will return the post type object
- if you’re on a category archive, it will return the category object
- if you’re on an author archive, it will return the author object
- etc.
function apoth_readmore_link( $content ) {
$post = get_queried_object();
if ( get_class($post)==='WP_Post' ) {
$url = get_post_meta($post->ID, 'original_url', true);
$content .= sprintf( '<a href="https://wordpress.stackexchange.com/questions/246324/%s">Read More</a>', $url, $url );
}
return $content;
}
add_filter('the_content', 'apoth_readmore_link' );
Related Posts:
- Is there any action filter/hook for validating a custom field before publishing the post?
- change attachment custom field onChange event
- Set new url from custom post field
- Add filter menu to admin list of posts (of custom type) to filter posts by custom field values
- Is there a way to set default custom fields when creating a post?
- Add subtitle to Woocommerce product title
- Filter WP_Query for posts having a certain meta-value
- Apply the_content filter to a custom field with multiple values
- Pass all custom fields through the same filter on post load?
- Filter results with custom field values and dropdown
- getEntityRecord without knowing the post type
- Archive sorting functions by custom fields (front-end)
- Get updated meta data after save_post hook
- Check before publishing, if already exist post with current custom field value
- Change content before writing to database
- post meta data clearing on autosave
- WordPress Search Custom Meta Field Only
- Display info from custom fields in all images’ HTML
- How do I assign this filter to a variable? (Appending php & markup to the_content)
- Update meta values with AJAX
- Add an advert every nth Paragraph
- How to filter a dd/mm/yyyy date from a custom field in a query
- Force hide custom field metaboxes
- Saving custom profile fields
- Registration and Profile custom field
- Update posts after populating ACF field value [closed]
- How to validate custom field on lost password form before the user id field?
- How to update a meta field of type array in Gutenberg
- filtering custom post types via meta data drop down
- global function to apply filter to custom field
- How to order posts by one custom field and filter them by another one?
- Send email with custom fields after new draft is saved or new post published
- Filter multiple custom fields Values with Check boxes
- How to get categories with posts by custom field value?
- Hook after meta created
- How to Wrote Simple Calculations by Using Custom Fields in Loop?
- Can’t save custom field on registration page
- Best filter to use for modifying custom fields on a post?
- How to display childrens custom fields?
- Access ACF fields within custom preview function?
- Sort posts by clicks on download button
- Best Way to get facebook share count and update using wp_schedule_event or any other method
- No result update a custom field using wp_schedule_event
- Let Users Filter Posts by Custom Fields
- Custom Theme Fields in Settings Menu – apply filters to one of those fields?
- Footnotes in custom fields
- How to change permalink on headlines in rss feeds?
- How to change order of posts in admin
- How to query posts by month based on date custom field?
- Filter or order based on custom field
- Using Custom Fields to Trigger Specific Actions on Saving a Post?
- How to show ACF fields in Gridbuilder custom block
- Why isn’t update_post_meta saving?
- WP meta_query args not working in function
- User Filter Options on Archive Page
- How to add content with a filter when there’s no content in the editor
- Filter and display a specific custom field value [closed]
- How to filter post using custom feild value in shortest and longest duration?
- Query Posts Via WordPress URL
- Change event firing in wordpress
- Incorrect data after modifying post using backlink from wp_die
- Create widget that filters posts on current page based on entered value
- Including inline Custom Fields info with add_filter in functions.php
- Sort posts after filtering them through multiple taxonomies
- How to automatically create a custom field when a post is published?
- Order shipped by which driver[hook for woocoomerce order staus changed and popup in admin panel ] [closed]
- Add custom fields to specific menus
- Difference between meta keys with _ and without _ [duplicate]
- Change behavior of “Insert into Post” based on attachment metadata
- Hook filter to change wp_upload_dir() path in multisite
- Is there a way to do multiple ordering on a multiple meta_query?
- Store JSON in a custom field
- Multiple custom fields with the same name
- BuddyPress – Hook to Update Custom Profile Fields [closed]
- Custom Fields Code not echoing whats in the value field
- Metabox will not save
- How to wrap meta values seperated by comma in ? [closed]
- Create WordPress shortcode with php code inside
- When does a function assigned to the content_filtered_edit_pre filter hook fire?
- ORDER BY custom field value out of where clause
- Filter WooCommerce Orders
- How to use filter to disable adding a product to wishlist?
- Save all custom field data into one “master” custom field
- Plugin or shortcode for ISBN number?
- WP-eComerce Advance Meta Tag data in descending order [closed]
- Replacing custom field with shortcode
- WPAlchemy issue when using 2 select menus with the same values inside a repeating group
- Is the use of many custom field not good for server?
- WordPress wp_get_current_user returning blank values until refresh
- Can you generate a featured image from two images from custom fields?
- Search fails when using the radio buttons
- query post based on comparison
- Custom Field add markup to line breaks
- Use Metabox to enter Post Title
- Include custom fields into the content of a regular page
- Bypassing a Form Options
- What filter or action to replace comments or add new comment system
- i want to send email on custom post field (job_status == 2) but it is not working
- Dynamically update Custom Fields to display new dates
- save all acf options in one meta_value [closed]