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.

Replacing entire tag with shortcode – JavaScript [duplicate]

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

Redirect user role to a specific page on login in a multisite network?

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

How to echo a PHP Code After the Content

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

How to make a “page-option” in WordPress

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(); ?>

Create form which redirects to site in network?

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