Display custom field on 404 page outside loop

You should not hide functionality in a template file. Templates are dumb, you don’t run unit tests on them normally. I’d recommend to move the logic to a separate function in your functions.php: function header_class( $default=”white” ) { $post = get_post(); // 404 pages, empty archives (user, taxonomy, date) if ( empty( $post ) ) … Read more

How to Disable WordPress Page Revisions?

By default, Pages and Posts support very similar things. The full list can be found on Trac. If we want to remove one of these post type features we can use the remove_post_type_support() function: function remove_posttype_supports() { remove_post_type_support( ‘page’, ‘revisions’ ); } add_action( ‘init’, ‘remove_posttype_supports’ ); The above you would need to put in your … Read more

How to remove ?p= from wordpress short links

I am not sure how you removed ?p= from the link but you can use get_shortlink filter to override the shortlink. You can refer following article for more details. http://www.wpbeginner.com/wp-themes/how-to-display-wordpress-shortlinks-in-your-theme/ Reference to get_shortlink filter: https://developer.wordpress.org/reference/hooks/get_shortlink/ Can you share some more details on how you removed the ?p= from the link?

Show About and Contact Us page when they’re clicked in the top menu.

You need to include a loop to retrieve the page content. Something like: <div id=”primary” class=”site-content”> <div id=”content” role=”main”> //BELOW HERE <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( ‘content’, ‘page’ ); ?> <?php comments_template( ”, true ); ?> <?php endwhile; // end of the loop. ?> //ABOVE HERE </div><!– #content –> </div><!– … Read more

How to show the number of website visitors in my theme

Here is what you need to use for the expected result: <p> Today’s Views: <span> <?php echo wp_statistics_visit(‘today’); ?> </span></p><br><br> <p>Yesterday’s Views: <span> <?php echo wp_statistics_visit(‘yesterday’); ?> </span></p><br><br> <p>All times Views: <span> <?php echo wp_statistics_visit(‘total’); ?> </span></p><br><br>

Search form does not work in my website

You’re missing the name of the search text input, so replace: name=”” with name=”s” Then take a look at searchform.php in the default themes, like Twenty Sixteen: <form role=”search” method=”get” class=”search-form” action=”<?php echo esc_url( home_url( “https://wordpress.stackexchange.com/” ) ); ?>”> <label> <span class=”screen-reader-text”><?php echo _x( ‘Search for:’, ‘label’, ‘twentysixteen’ ); ?></span> <input type=”search” class=”search-field” placeholder=”<?php echo … Read more

How can i show post_class() within output loop?

You should use get_post_class() From Codex: get_post_class() is not simply a non-echoing alternative to post_class(). get_post_class() does not return a string, but an array that must be processed to produce text similar to what is echoed by post_class(). So $classes = get_post_class(); $output=”<div id=”” . get_the_ID() . ‘” class=”‘ . implode(” “, $classes) . ‘”></div>’;