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
- Is it possible to use get_post_meta() to control HTML?
- Editing custom fields for comments
- using custom fields on content.php file of my theme
- get_post_meta returns 0
- Hide / Show Custom field depending of the page ID (Magic Field 2)
- How to show certain data on certain interval of period
- How do I include a template file while allowing it to render its own dynamic content added via custom box?
- wordpress get_post_meta / the_meta to output custom field value
- plugin-list-category-post custom fields
- How to Convert Custom Fields from Text to Array?
- Changing the text of Upload/Insert on Posts and Pages Screen
- How to query for posts with either one or another custom field
- Multiple Custom Field Query
- How show post only from after custom date
- Custom Meta Box Upload Image Problem
- Best way to sort estates and query them (for rent? yes/no. contains office space? yes/no)?
- Populate wordpress menu with link to custom field value (file download)
- How to show content of custom fields in search results?
- Stripping and/or altering the content of a custom field (video URL)
- How to display data from custom fields I created?
- Custom Query: query by post custom meta data
- Custom field outside the loop and inside an array
- Get array of posts based on custom field values
- Selectively hiding or allowing thumbnails of featured images on front page
- Where exactly does the edit_{taxonomy} hook fire?
- How to order posts by number of Vimeo Likes
- Displaying a video on the homepage via a custom field inside a php widget
- Is it possible to compare the current time with a custom “start” and “end date
- Show Custom Field of Current Page in For Loop
- Display metabox title for custom fields with values
- WP E-Commerce Custom Meta > Serialized array
- Custom Field & Gravity Forms [closed]
- Filter search posts by post meta?