• Hi there,

    I use a sticky post as welcome message at my website but all posts are linked to the
    single post page. Therefore I would like to disable the link of one specific post or category..

    I tried removing the link part of this code snippet from the content.php but that disables all post title links.

    <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>

    Hope you can help! Thanks in advance.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Well.. do you want to disable the link on one specific post… or one entire category?

    If post… then you will need to get the “post ID”.
    If category.. then you will need to get the “category slug”.

    Once you make this decision, and get the appropriate information, then you can modify your code above to first check if it is that specific post or category… then proceed to display the link… or not.

    Thread Starter Chris

    (@christof15)

    Hi Josh, thanks for your response.. Could you please tell me how to do that?
    Yes one post would be good for me. The post ID is 127.
    If you could tell how to do it for a specified category it would be great too!
    The category slug is ‘welkom’.

    Thanks again!

    You bet ??

    Okay.. on your code… if we are checking for a specific page, let’s try this:

    if(!is_page(127)) {
        <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
    }

    If we are using a category; it will appear as so:

    if(!is_category('welkom')) {
        <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
    }

    Lastly… if we wanted to do BOTH posts AND categories:

    if(!is_page(127) || !is_category('welkom')) {
        <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
    }

    EDIT: Depending on how you have things setup… you may have to use is_single() instead of is_page(). But, let’s try the above first.

    Thread Starter Chris

    (@christof15)

    Thank you! Can you tell me how to put it exactly in the content.php code? Or is it possible with css only?

    <?php
    /**
     * The default template for displaying content
     *
     * Used for both single and index/archive/search.
     *
     * @package WordPress
     * @subpackage Twenty_Thirteen
     * @since Twenty Thirteen 1.0
     */
    ?>
    
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    	<header class="entry-header">
    		<?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
    		<div class="entry-thumbnail">
    			<?php the_post_thumbnail(); ?>
    		</div>
    		<?php endif; ?>
    
    		<?php if ( is_single() ) : ?>
    		<h1 class="entry-title"><?php the_title(); ?></h1>
    		<?php else : ?>
    		<h1 class="entry-title">
    			<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
    		</h1>
    		<?php endif; // is_single() ?>
    
    		<div class="entry-meta">
    			<?php twentythirteen_entry_meta(); ?>
    			<?php edit_post_link( __( 'Edit', 'twentythirteen' ), '<span class="edit-link">', '</span>' ); ?>
    		</div><!-- .entry-meta -->
    	</header><!-- .entry-header -->
    
    	<?php if ( is_search() ) : // Only display Excerpts for Search ?>
    	<div class="entry-summary">
    		<?php the_excerpt(); ?>
    	</div><!-- .entry-summary -->
    	<?php else : ?>
    	<div class="entry-content">
    		<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentythirteen' ) ); ?>
    		<?php wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
    	</div><!-- .entry-content -->
    	<?php endif; ?>
    
    	<footer class="entry-meta">
    		<?php if ( comments_open() && ! is_single() ) : ?>
    			<div class="comments-link">
    				<?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a comment', 'twentythirteen' ) . '</span>', __( 'One comment so far', 'twentythirteen' ), __( 'View all % comments', 'twentythirteen' ) ); ?>
    			</div><!-- .comments-link -->
    		<?php endif; // comments_open() ?>
    
    		<?php if ( is_single() && get_the_author_meta( 'description' ) && is_multi_author() ) : ?>
    			<?php get_template_part( 'author-bio' ); ?>
    		<?php endif; ?>
    	</footer><!-- .entry-meta -->
    </article><!-- #post -->

    Okay… again, it’s kind of hard to say specifically… without knowing your exact, specific intentions..

    But.. let’s try this.
    https://pastebin.com/zwjeehSi

    Copy and paste the entire contents of that pastebin into your content.php file.

    NOTE: If this is part of your current themes files.. then your changes will be over-written the next time you update your theme. Instead, you should be using a child theme to preserve your changes.

    Thread Starter Chris

    (@christof15)

    Hmm okay I tried your pastebin content.php within my child theme but unfortunately it did not work.

    My goal is to disable the linking of one specified post title because I use that post as a sticky welcome message on the homepage. I was already able to hide the meta information of this post by putting this css into my style.css

    #post-127 .entry-meta {
    display:none;
    }

    I really appreciate your help! Thanks again:)

    but unfortunately it did not work.

    What exactly did not work?
    Did you receive an error?
    Did any content whatsoever show up?
    Does it still display the title, but without a link?

    Specifics on how exactly it didn’t work will help me to further refine the code ??

    Try this pastebin:
    https://pastebin.com/eCXKMdcE

    Thread Starter Chris

    (@christof15)

    Nothing happened. I cleared all cache but still the title was linked.
    I did not receive an error etc.. It still display the post title with link.
    Also with the new pastebin still nothing happens..

    Okay.. what is the weburl where these posts are displaying?

    Thread Starter Chris

    (@christof15)

    Hi Josh, i’ve send you a pm at your email. Thanks!

    Answered you back ??

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Disable specific post title link’ is closed to new replies.