Display theme's custom field

Posted in: Newspaper
Post count: 11


add_filter( 'post_link', 'wpse_64285_external_permalink', 10, 2 );

function wpse_64285_external_permalink( $link, $post )
{

$meta = get_post_meta( $post->ID, 'td_source_url', TRUE ); //this doesn't work why, as we know this is our field name td_source_url

//get_post_meta( $post->ID, 'syndication_permalink', TRUE ); // <----- this works
$url = esc_url( filter_var( $meta, FILTER_VALIDATE_URL ) );
// echo $url ? $url : $link;
return $url ? $url : $link;
}

This should work but isn’t working, can you point me to the right direction ?

Post count: 35449

Hello,

Please provide some more details about this code, for what it is and what should do, also where it was set when it works, also some screenshots with the settings would be very helpful.

Thank you!

Post count: 11

What I’m trying to achieve is to use theme’s custom field or meta box named source URL to replace post link so that it can be open as an external post (redirects to other’s website without opening our post) i.e to change its post_link using that hook.
so all I need is to get the value of td_source_url and that code will work.
1. https://nimb.ws/YzXpFn

Post count: 35449

Hello,

This can be achieve only with custom work, is need to make a function to get the post title and set the source url instead post title, this function can be find in wp-content/plugins/td-composer/legacy/common/wp_booster/td_module.php -> http://prntscr.com/phs4fn also the title is call on each module from blocks -> http://prntscr.com/phs4p9

If you want to implement this custom, you can check our custom services from here -> https://tagdiv.com/premium-customization-services/

Thank you!

Post count: 11

I think you may have misunderstood me,
There is a filter post_link in wordpress and I’m using that to link.
I just need to get value from the theme’s custom field Source URL
Normally get_post_meta( $post->ID, 'td_source_url', TRUE ); works but not with your theme’s custom field. Can you find out how can I get value of SOURCE URL from your theme’s custom field?

Thanks

Post count: 35449

Hi,

Our function for this is in wp-content/plugins/td-composer/legacy/common/wp_booster/td_module_single_base.php -> http://prntscr.com/phw4k3 and can be add in loop-single-x.php like this -> http://prntscr.com/phw6bq

Thank you!

Post count: 11

How can I access this from function.php as
get_post_meta( $post->ID, 'td_source_url', TRUE );
this won’t work?

Post count: 35449

Hi,

Please notice that this is a custom implementation and this is not cover by our support policy, all I can do is to show you the function that you need in our theme and how this is implement on posts, if you want to make some customization in theme files, you’ll need to do it your self or hire a developer.

Thank you for your understanding!

Viewing 8 posts - 1 through 8 (of 8 total)
The forum ‘Newspaper’ is closed to new topics and replies.