• I put a code so my title act like link, but now I have problem 🙂 If title is “Hello” it display Hello Hello. First Hello is link, another is not.

    this is my code

    <?php
    $columns = new WP_Query(array(
    
    		'category_name'=>'Multimedija'
    
    	));
    
    	$count = 0;
    
    ?>
    
    	<div class="slides">
    
    		<div class="slides_container">
    
    <?php
    
    	if ($columns->have_posts()) :
    
    		$count = 0;
    
    			while ($columns->have_posts()) : $columns->the_post();
    
    			$count++;
    
    ?>
    
    			<div class="slide">
    
    				<div class="slides_thumbnail">
    
    					<a>">
    
    						<div style="width:190px;height:190px;background:url('<?php 
    
    						 $img = get_the_post_thumbnail();
    
    						eregi("src=\"([^\"]+)\"", $img, $arr);
    
    						echo $arr[1]; ?>');"> </div>
    
    						<span class="image overlay"></span>
    
    						<span class="description"></span>
    
    					</a>
    
    				</div><!-- .slides_thumbnail -->
    
    				<h3 class='slide_title'>
    
    <a>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    					<?php
    
    						$long_title = strip_tags(htmlspecialchars(get_the_title($post->ID)));
    
    						$short_title = substr($long_title,0,40);
    
    						if (strlen($long_title) !== strlen($short_title)) {
    
    							echo $short_title . "... ";
    
    						} else {
    
    							echo $short_title;
    
    						}
    
    						?>
    
    				</h3><!-- .slide_title -->
    
    				<div class='slide_stats'>
    
    					<?php $more_comments = get_comments_number() . '  Komentar(a)'; ?>
    
    					<?php comments_number( "0 Komentar(a)", "1  Komentar(a)", $more_comments ); ?> 
    
    				</div><!-- .slide_stats -->
    
    				<div class="slides_text">
    
    					<p>
    
    						<?php 
    
    							if(function_exists('the_excerpt_max_charlength')) {
    
    								the_excerpt_max_charlength(300); 
    
    							} else {
    
    								the_excerpt(); 
    
    							}
    
    						?>
    
    					</p>
    
    				</div><!-- .slides_text -->
    
    			</div><!-- .slide -->
    
    <?php
    
    		endwhile;
    
    	endif;
    
    ?>
    
    		</div><!-- .slides_container -->
    
    <?php
    
    	if($count > 1) :
    
    ?>
    
    			<button class="slide_prev">Previous</button>
    
    			<button class="slide_next">Next</button>
    
    <?php
    
    	endif;
    
    ?>
    
    </div><!-- .slides -->

    [Please post code or markup snippets between backticks or use the code button. As it stands, your posted code has been permanently damaged/corrupted by the forum’s parser.
    for large amounts of code, please use the pastebin – http://codex.ww.wp.xz.cn/Forum_Welcome#Posting_Code ]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi,

    There is something wrong here with the quote, and there is not href for destination :
    <a>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>

    Function Reference/the title attribute
    Displays or returns the title of the current post. It somewhat duplicates the functionality of the_title(), but provides a ‘clean’ version of the title for use in HTML attributes by stripping HTML tags and converting certain characters (including quotes) to their character entity equivalent; it also uses query-string style parameters. This tag must be within The Loop.
    http://codex.ww.wp.xz.cn/Function_Reference/the_title_attribute

    Try this :
    <a href="<?php echo get_permalink(); ?>" title="permalink to <?php the_title(); ?>"><?php the_title(); ?></a>

    Thread Starter gala1929

    (@gala1929)

    Thank you, I’ve try this now, but it’s still same problem 🙁

    You still have 2 times the same word (1 link is working and 1 is not a link) ?

    Thread Starter gala1929

    (@gala1929)

    yes

    There is something wrong here too :

    <a>">
    <div style="width:190px;height:190px;background:url('<?php
    $img = get_the_post_thumbnail();
    eregi("src=\"([^\"]+)\"", $img, $arr);
    echo $arr[1]; ?>');"> </div>
    <span class="image overlay"></span>
    <span class="description"></span>
    </a>

    And you shouldn’t use CSS style to call/display post thumbnail as link !

    Thread Starter gala1929

    (@gala1929)

    Any ideas?

    please re-post the full code as it is now –

    how-to http://codex.ww.wp.xz.cn/Forum_Welcome#Posting_Code

    btw, this section is also outputting the title:

    $long_title = strip_tags(htmlspecialchars(get_the_title($post->ID)));
    
    						$short_title = substr($long_title,0,40);
    
    						if (strlen($long_title) !== strlen($short_title)) {
    
    							echo $short_title . "... ";
    
    						} else {
    
    							echo $short_title;
    
    						}

    I don’t know for this portion of code because I don’t know what was used behind ‘eregi

    But in a near future, why don’t you do this kind of thing :

    <a href="<?php echo get_permalink(); ?>" title="permalink to <?php the_title(); ?>"><?php the_title(); ?><img src="the_post_thumbnail('thumbnail');"></a>

    Sure, it depends who your WordPress thumbnails template has been implemented in the theme by the theme’s developper.

    Thread Starter gala1929

    (@gala1929)

    <?php
    	$columns = new WP_Query(array(
    		'category_name'=>'Multimedija'
    	));
    
    	$count = 0;
    ?>
    	<div class="slides">
    		<div class="slides_container">
    <?php
    	if ($columns->have_posts()) :
    		$count = 0;
    			while ($columns->have_posts()) : $columns->the_post();
    			$count++;
    ?>
    			<div class="slide">
    				<div class="slides_thumbnail">
    					<a href="<?php the_permalink(); ?>">
    						<div style="width:190px;height:190px;background:url('<?php
    						 $img = get_the_post_thumbnail();
    						eregi("src=\"([^\"]+)\"", $img, $arr);
    
    						echo $arr[1]; ?>');"> </div>
    
    						<span class="image overlay"></span>
    						<span class="description"></span>
    					</a>
    				</div><!-- .slides_thumbnail -->
    				<h3 class='slide_title'>
    					<?php
    
    						$long_title = strip_tags(htmlspecialchars(get_the_title($post->ID)));
    						$short_title = substr($long_title,0,55);
    
    						if (strlen($long_title) !== strlen($short_title)) {
    							echo $short_title . "... ";
    						} else {
    							echo $short_title;
    						}
    						?>
    				</h3><!-- .slide_title -->
    
    				<div class='slide_stats'>
    					<?php $more_comments = get_comments_number() . '  Komentar(a)'; ?>
    					<?php comments_number( "0 Komentar(a)", "1  Komentar(a)", $more_comments ); ?>
    				</div><!-- .slide_stats -->
    
    				<div class="slides_text">
    					<p>
    						<?php
    							if(function_exists('the_excerpt_max_charlength')) {
    								the_excerpt_max_charlength(300);
    							} else {
    								the_excerpt();
    							}
    						?>
    					</p>
    				</div><!-- .slides_text -->
    			</div><!-- .slide -->
    <?php
    		endwhile;
    	endif;
    ?>
    		</div><!-- .slides_container -->
    <?php
    	if($count > 1) :
    ?>
    			<button class="slide_prev">Previous</button>
    			<button class="slide_next">Next</button>
    <?php
    	endif;
    ?>
    </div><!-- .slides -->
Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Link title’ is closed to new replies.