• Error 👉 
    Notice: Undefined variable: post_id in /home/u199577564/domains/freesarkarijobalert.in/public_html/wp-content/themes/FreeSarkariJobAlert.in-Theme/single.php on line 41

    In my website every post I got this error message. How can I fix this issue please help me where & What coding I have to use. Here I providing you the coding which available in my website themes. 👇

    
    1
    <?php
    2
    get_header(); 
    3
    ?>
    4
    <center>
    5
    <style>
    6
    table a{
    7
      color:blue;
    8
      font-weight:700;
    9
    ​
    10
    }
    11
    table h1{
    12
      color:#222222;
    13
    font-weight:800;
    14
    ​
    15
    }
    16
    table h2{
    17
      color:;
    18
    font-weight:700;
    19
    ​
    20
    }
    21
    table h3{
    22
      color:green;
    23
    font-weight:700;
    24
    ​
    25
    }
    26
    table h4{
    27
      color:#ff00ff;
    28
    font-weight:700;
    29
    ​
    30
    }
    31
    table b{
    32
      color:red;
    33
      font-weight:700;
    34
    ​
    35
    }
    36
    ​
    37
    </style>
    38
    <div style="width:75%;height:auto;margin-top:0px;">
    39
    <table style="width:100%;height:auto;">
    40
    <tr>
    41
    <td style="width:55%;"><h1><?php echo get_the_title( $post_id ); ?></h1><hr>
    42
    ​
    43
        <?php if ( have_posts() ) : ?>
    44
        <?php while ( have_posts() ) : the_post(); ?>
    45
        <div <?php post_class(); ?>>
    46
            <?php the_content(); ?>
    47
            <?php edit_post_link(); ?>
    48
            <?php wp_link_pages(); ?> 
    49
        </div>
    50
    <?php endwhile; /* rewind or continue if all posts have been fetched */ ?>
    51
    <?php else : ?>
    52
    <?php endif; ?>
    53
        
    54
        
    55
    <td style="width:20%;">Responsive Ads Here!</td>
    56
    </tr>
    57
    </table>
    58
        <div id="copy"> © Copyright 2018-2019 at <a href="<?php bloginfo('url'); ?>"><?php bloginfo('url'); ?></a>
    59
    <br />For advertising in this website contact us <a href="https://freesarkarijobalert.in/contact-us">admin@freesarkarijobalert.in</a><br><br></div></br>
    60
    </div>
    61
    </center>
    62
    <?php get_footer(); ?>
    63
    ​
    • This topic was modified 6 years, 4 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Everything else WordPress topic

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • You don’t have to use $post_id into the single.php file. It should work without $post_id.

    
    <h1><?php echo get_the_title(); ?></h1>
    
    Thread Starter imranmkg786

    (@imranmkg786)

    Thanks a lot it’s working ……..

    In my category post I found below issue

    Notice: Undefined variable: post_id in /home/u199577564/domains/freesarkarijobalert.in/public_html/wp-content/themes/FreeSarkariJobAlert.in-Theme/archive.php on line 18
    PSC IDO Exam Official Answer Key

    In That Archive.php line Code is :-
    <li><a href="" target=_blank><a href="<?php the_permalink(); ?>" target=_blank><?php echo get_the_title( $post_id ); ?></a> </a></li>

    But I tried as per your suggestion on same method ,I use below code and it’s working fine till now there have Any chance to create problem in future or using code is Ok …
    <a href="<?php the_permalink(); ?>" target=_blank><?php echo get_the_title(); ?></a>

    THANKS AGAIN…..

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘notice: undefined variable: post_id in /home/’ is closed to new replies.