WordPress.org

Ready to get started?Download WordPress

Forums

PHP code help needed Tabs and Titles (8 posts)

  1. Wongshag
    Member
    Posted 8 months ago #

    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.

  2. Wongshag
    Member
    Posted 8 months ago #

    Sorry that first line should say Template

  3. Howdy_McGee
    Member
    Posted 8 months ago #

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

  4. LeopardOnTheLoose
    Member
    Posted 8 months ago #

    Try:

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

  5. jmeyer2485
    Member
    Posted 8 months ago #

    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:http://www.example.com/archives) I want (example | site is blah blah)

    Thanks.

    <font size="5"><a href="http://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; ?>
  6. esmi
    Theme Diva & Forum Moderator
    Posted 8 months ago #

    @jmeyer2485: As per the Forum Welcome, please post your own topic.

  7. Wongshag
    Member
    Posted 8 months ago #

    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>
  8. Wongshag
    Member
    Posted 8 months ago #

    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

Reply

You must log in to post.

About this Topic