I have a custom post type "article" & I need to display some custom urls is a widget in the sidebar using php code widget
.
When I use this code withing the loop it works perfectly:
<a href="<?php echo site_url('/article/full-text/'); ?>
<?php $slug = $post->post_name; echo $slug; ?>" title="<?php the_title_attribute(); ?>">Full Text</a>
but when I put this code in the php code widget it displays only the first part of the url.
To be more clear, when I use this code within the loop the url will be (www.my-site.com/article/full-text/article-title
). But in the php code widget the url will be (www.my-site.com/article/full-text/
).
Am I missing something here? Any help please?
get_permalink( id );
where id == post/page/cpt id ?