• I have this in a temple:
    <a class="slide-link" href="#tab-<?php the_ID(); ?>">

    It shows links on my pages on hover as xxxxx.com/#tab-453

    I want it to show the actual post name not the ID.

    I tried:
    <a class="slide-link" href="#tab-<?php the_ID(); ?><?php echo the_title(); ?>">

    But that shows xxxxxx.com/#tab-453 pinotage wine

    If I replace the the_ID with the_title my javascript in the template does not work. How do I code it so javascript uses the tab ID but shows the Page or Post Title as the link?

    Any help greatly appreciated.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Wongshag

    (@wongshag)

    Sorry that first line should say Template

    the_ID() must be used inside the loop. You could try echo $post->ID instead. Are you in the loop though?

    Try:

    <a class="slide-link" href="<?php the_permalink();?>"> <?php the_title();?> </a>

    This is not really the same but can someone tell me what I need to add to this code to get my SEO title to show up in browser tab instead of the url (example:https://www.example.com/archives) I want (example | site is blah blah)

    Thanks.

    <font size="5"><a href="https://www.URL.com/">Home</a></font>  <------------ Just in-case you got lost.
    <?php
    /*Template Name: Archives*/
    ?>
    <?php
    $posts_to_show = 100; //Max number of articles to display
    $debut = 0; //The first article to be displayed
    ?>
    <?php while(have_posts()) : the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <?php get_search_form(); ?>
    <ul>
    <?php
    $myposts = get_posts('numberposts=$posts_to_show&offset=$debut');
    foreach($myposts as $post) :
    ?>
    <li><?php the_time('m/d/Y') ?>: <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    
    <?php endforeach; ?>
    </ul>
    
    <?php endwhile; ?>

    Thread Starter Wongshag

    (@wongshag)

    Thanks Howard and Leopard. Both options mess up my javascript. I presume it is in the loop – here is my entire original code from the section we are discussing:

    <div class="product-section">
            	<?php $count=0; while(have_posts()): the_post();?>
    				<?php if($count%4==0):?>
                        <div class="row">
                            <div class="tabset">
                            <?php endif;?>
                                <a class="slide-link" href="#tab-<?php the_ID(); ?>">
                                <?php the_post_thumbnail('wine_thumbnail', array('class' => 'alignleft')) ?>
                                    <span class="description" >
                                        <strong class="title"><?php the_title() ?></strong>
                                        <span class="text" ><?php echo strip_tags(get_the_excerpt()) ?></span>
                                        <span class="link" >Read more</span>
                                    </span>
                                    <em class="decor"></em>
                                </a>
                            <?php  $count++;?>
                            <?php if($count%4==0):?>
                            </div>

    Thread Starter Wongshag

    (@wongshag)

    Is there any way of using the line <a class="slide-link" href="#tab-<?php the_ID(); ?>"> but adding to it some code that shows the post name but allows the javascript to use the #tab bit?

    Many of the edit changes I have made cause the whole layout of the site to change, in a major way. I have added code to make the hover show xxx/com/wines/#tab-143pinotage-chenin-blanc which is almost there I just then need to hide the #tab-143 bit.

    Sounds a bit unclear but that’s what I need

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘PHP code help needed Tabs and Titles’ is closed to new replies.