Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Theme Development for a Newbie

Looking at your code (as i do not see any live link to look at). I will assume you are outputting anchor tag inside a button tag (making the HTML invalid). Try the function below instead. Notice that I changed the html from button to anchor tag.

    /**
     * Add Login/Logout to Menu
     */
    function add_login_logout_link($items, $args) {

        $redirect_to = home_url();

        if( $args->theme_location == 'primary' ) {
            $loginoutlink = wp_loginout('index.php', false);

            $link = wp_logout_url($redirect_to);
            $label="Logout";

            if(!is_user_logged_in()){ // user not logged in, show login url
                $link = wp_login_url( $redirect_to );
                $label="Login";
            }

            $items .= '<li><a class="btn btn-default" href="'. $link .'">'. $label .'</a></li>';

        }

        return $items;
    }

add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);

Using Output Buffer

Only use output buffer when you have to. This has potential to create unusal behavior. Here is an example.

Related Posts:

  1. How to modify an image block in Gutenberg WordPress 5?
  2. What is the problem if I use CDN in my WordPress parent theme(built using bootstrap)?
  3. Excess White Space Above Admin Bar on Frontend Using Twitter Bootstrap
  4. How to Modify a Widgets UL and/or LI Classes
  5. customizing the_password_form filter
  6. Custom Theme Bootstrap
  7. JavaScript Change focus to password field login page being reset
  8. Developing WordPress Theme using CSS framework like Bootstrap
  9. Bootstrap card columns change images size
  10. WP_bootstrap_Navwalker_issue [closed]
  11. How to create first post, fifth post full width, rest in three columns and so on
  12. Javascipt issue on custom theme
  13. Second menu has the first menu ID
  14. How to style bootstrap container in wordpress theme?
  15. is using the_posts_navigation() required?
  16. Adding Bootstrap to WordPress TwentySixteen Theme
  17. Bootstrap grid system is not working in my WordPress theme
  18. Full width featured thumbnail
  19. Why I obtain different visualization when I run the website on my local machine and on remote server?
  20. How to create a WP theme that use BootStrap? [closed]
  21. I don’t think WordPress is loading jquery or bootstrap js
  22. How do I keep my iframes responsive and scaled to fit their container?
  23. change background image on scroll
  24. two col layout bootstrap 4 with one fixed col and fade in effect on image
  25. style.css not being rendered in browser
  26. wordpress thumbnail onclick then modal will come out
  27. Full width thumbnail
  28. Code for creating three vertical columns in WordPress Bootstrap theme
  29. How do I get my theme scripts to load in a custom theme built from Bootstrap
  30. Why the slideshow is not shown in my theme?
  31. WordPress Loop with Custom Post Type for Bootstrap Accordion [closed]
  32. How To add li class and a class wp_nav_menu() with bootstrap 5 navbar?
  33. Bootstrap 4 mobile menu not working for WordPress Development
  34. Dropdown Toggle Split in Bootstrap Navwalker WordPress
  35. Starter Bootstrap and Custom Fonts
  36. Menu items description? Custom Walker for wp_nav_menu()
  37. How to define and link full path to css located at a random folder on header.php
  38. Sizing screenshot.png without losing aspect ratio
  39. Software for WordPress Theme and Plugin Development? [closed]
  40. When to use is_home() vs is_front_page()?
  41. What is the preferred way to add custom javascript files to the site?
  42. Get the blog page URL set in Options
  43. How to create .pot files with POedit?
  44. How do I get the theme URL in PHP?
  45. Why when I submit a form in wordpress it loads a 404 page though URL is correct
  46. What is the constant WP_USE_THEMES for?
  47. Worthwhile to restrict direct access of theme files?
  48. How Do I Protect My Premium WordPress App Theme from Copying?
  49. How to detect mobile devices and present them a specific theme?
  50. Using wp_add_inline_style without a stylesheet
  51. How to add posts to custom menus?
  52. WordPress Theme Preview Image
  53. How To extend WP_Customize_Control
  54. What is the difference between front-page.php and home.php? [duplicate]
  55. How can I get page slug
  56. Does the functions.php file ever get called during an AJAX call? Debug AJAX
  57. When to use _e and __ for the translation?
  58. What is a Theme textdomain?
  59. How to show a custom meta box on the “Quick Edit” screen?
  60. How to add CSS class to custom logo?
  61. How to add custom css file in theme?
  62. How important is it to enqueue a theme’s stylesheet?
  63. CSS not updating in browser when I change it
  64. Display Search Result Count
  65. wp_nav_menu(), how to change class?
  66. theme path in javascript file
  67. Is wp_is_mobile() effective?
  68. Display Menu Name using wp_nav_menu
  69. Making update notification functionality for my themes
  70. What questions do you ask when asked to give an estimate on theme development?
  71. How to remove dashicons.min.css from frontend?
  72. How do I remove a pre-existing customizer setting?
  73. Minimum Template Files for Theme Development
  74. What’s the difference between home.php and index.php?
  75. pass object/JSON to wp_localize_script
  76. get_template_part vs action hooks in themes
  77. Theme Activate Hook
  78. Solutions for generating dynamic javascript / CSS
  79. wp_redirect() – headers already sent
  80. Can I create my own “Recent Posts” widget or customize the existing one?
  81. Custom single template for a specific category
  82. how can I add an icon/image for a child theme?
  83. How can I add a URL field to the attachments window?
  84. The the_post_thumbnail without srcset?
  85. The proper way to include/require PHP files in WordPress
  86. Get the first image from post content (eg.: hotlinked images)
  87. after_setup_theme always runs
  88. When to use add_action(‘init’) vs add_action(‘wp_enqueue_scripts’)
  89. Getting failure when using filemtime() with wp_enqueue_style
  90. Do I actually need to link my theme’s style.css in the theme files
  91. Why is wp_head() creating a top margin at the top of my theme header?
  92. How to store widget fields data as an array?
  93. How do I add version control to my workflow?
  94. Using classes instead of global functions in functions.php
  95. WordPress API Menu/Submenu Order
  96. How can I display a menu on certain pages only?
  97. Enqueue a stylesheet for login page and make it appear in head element
  98. Adding a div to wrap widget content after the widget title
  99. How to insert a logo in the header?
  100. How to set permalink structure via functions.php
Categories theme-development Tags theme-development, twitter-bootstrap, wp-login-form
Import of 200+ sermons
different CNAME to corresponding subfolders

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress