Thumbslinger Posted October 21, 2019 Share Posted October 21, 2019 Hello- I am not generating any errors with this php snippet which is in my functions.php file of the child theme for wordpress but I'm wondering why it doesn't work. Snippet: function pnavi_shortcode() { return get_the_post_navigation(); }add_shortcode ( 'pnavi', 'pnavi_shortcode' ); I have also tried using a variable = to the function of get_the_post_navigation() but same issue. This script is supposed to show the previous - next navigation for pages of posts, not the 'next' single post. Via a theme, it is working, but I'm trying to add something myself in another location. Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/309393-writing-a-shortcode-function-for-wordpress/ Share on other sites More sharing options...
maxxd Posted October 23, 2019 Share Posted October 23, 2019 (edited) Describe "working" and "not working". I've just eaten and had a couple glasses of wine so I may be missing something glaring, but the code you've posted should work. Of course, that assumes your query returns more than one page of posts. Edited October 23, 2019 by maxxd Quote Link to comment https://forums.phpfreaks.com/topic/309393-writing-a-shortcode-function-for-wordpress/#findComment-1570903 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.