PHP Error in WordPress Theme
Replcace this function start_el(&$output, $item, $depth, $args) { …. with this function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { …. I hope this will work.
Replcace this function start_el(&$output, $item, $depth, $args) { …. with this function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { …. I hope this will work.
You can get a list of posts created by each user using /author/{username} Eg : https://www.wpbeginner.com/author/wpbeginner/
This looks like javascript. do_shortcode is a php function. I’m not sure the full context, but at the very least, you need to wrap your php function in php tags like this and add an echo: <?php // Start of php file ?> <script> var stockcounter = document.getElementsByClassName(“stock in-stock”); if(stockcounter[0].innerHTML==’0 in stock’) { //Displays timer … Read more
If you want to perform any redirects, you have to send your header before site sends any output. admin_head is an action that allows you to print your custom code inside <head> tag of admin sites. But if it’s inside of <head>, then some output is already sent to the browser, so you can’t perform … Read more
spl_autoload_register is slow for WordPress sites
Handling form actions in WordPress
Here’s the solution if anyone’s interested: add_filter(‘login_redirect’, function( $url, $query, $user ) { $user_info = get_userdata($user->ID); return get_blogaddress_by_id($user_info->primary_blog) . ‘wp-admin/?login=1’; }, 10, 3); add_action(‘current_screen’, function ( $user ) { $userID = get_current_user_id(); $user_info = get_userdata($userID); if ($_GET[‘login’] == 1 && $user_info->primary_blog) { $primary_url = get_blogaddress_by_id($user_info->primary_blog) . ‘wp-admin/edit.php?post_type=visitor’; $site_id = $user_info->primary_blog; if (!current_user_can_for_blog($site_id, ‘create_users’)) { wp_redirect( … Read more
You can try my approach which is used to do your requirement: function themename_your_content_after($content) { if( is_single() ): ob_start(); ?> <div class=”css”> <?php if ( should_display_link() ) : ?> [subscribe-author-button] <?php echo ‘<a class=”btn” style=”background-color:#1f1fff; border-radius:100px;” href=”‘.site_url(‘chat/’).’?new-message&to=’.get_the_author_meta( ‘user_login’ ).'”>Chat</a>’ ; ?> <?php endif; ?> [simple-author-box] <?php if ($post->post_status == “publish”) { ?> <h4>[post-views]</h4> <?php } … Read more
You can define a specific page template for the specific widget then you can select template page as on your navigation menu. <?php /* Template Name: page one */ get_header(); ?> <div class=”main-wrap “> <?php if (is_active_sidebar( “widgetName” )) { dynamic_sidebar( “widgetName” ); } ?> </div> <?php get_footer(); ?>
You could perform a validation through get_blog_id_from_url($domain, $path) function, assuming you are using directories and NOT subdomains. Otherwise, $path is not required. See code and comments below. <?php if ( ! empty( $_POST[‘sitename’] ) ) { $main_site_url = network_site_url( “https://wordpress.stackexchange.com/” ); $domain = preg_replace( “/^https?:\/\/(www)?/”, ”, $main_site_url ); $path = preg_replace( “/\//”, ”, trim( $_POST[‘sitename’] … Read more