Getting the permalink by an option from settings api
-
I am currently using the code from https://alisothegeek.com/2011/01/wordpress-settings-api-tutorial-1/ for my theme’s settings which a have settings where users can input the page slug of an existing page.
My question and problem is, how can i output the permalink of the page slug inputted on those settings?
I tried this,
$termspage = mytheme_option( 'terms_page' ); function get_permalink_by_slug($page_slug, $output = OBJECT, $post_type = 'page' ) { global $wpdb; $page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type= %s", $page_slug, $post_type ) ); return get_permalink($page, $output); } echo get_permalink_by_slug($termspage);
I also tried,
echo get_permalink(mytheme_option( 'terms_page' ));
But both of them is not working..
Please help..
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Getting the permalink by an option from settings api’ is closed to new replies.