1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development Wordpress coding help

Discussion in 'Tech Support' started by GaryP, 16 Mar 2019.

  1. GaryP

    GaryP RIP Tel

    Joined:
    31 Aug 2009
    Posts:
    5,311
    Likes Received:
    759
    I don't know if anyone here does much with wordpress but I am trying to change the way news is displayed on a site for my friend's village club website.

    I am trying to make the news appear as an excerpt and then click onto full article. The theme will do that after a search but not in general.

    I have asked about on the the net for help and been kind of talked down to for not knowing anything. I'll post the code here and if someone could take a look for me I'll be really grateful.

    The content.php file shows clearly that only search will show excerpt.

    Code:
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <header class="entry-header">
            <h1 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    
            <?php if ('post' == get_post_type()) { ?>
            <div class="entry-meta">
                <?php bootstrapBasicPostOn(); ?>
            </div><!-- .entry-meta -->
            <?php } //endif; ?>
        </header><!-- .entry-header -->
    
        
        <?php if (is_search()) { // Only display Excerpts for Search ?>
        <div class="entry-summary">
            <?php the_excerpt(); ?>
            <div class="clearfix"></div>
        </div><!-- .entry-summary -->
        <?php } else { ?>
        <div class="entry-content">
            <?php the_content(bootstrapBasicMoreLinkText()); ?>
            <div class="clearfix"></div>
            <?php
            /**
             * This wp_link_pages option adapt to use bootstrap pagination style.
             * The other part of this pager is in inc/template-tags.php function name bootstrapBasicLinkPagesLink() which is called by wp_link_pages_link filter.
             */
            wp_link_pages(array(
                'before' => '<div class="page-links">' . __('Pages:', 'wmillock') . ' <ul class="pagination">',
                'after'  => '</ul></div>',
                'separator' => ''
            ));
            ?>
        </div><!-- .entry-content -->
        <?php } //endif; ?>
    
        
        <footer class="entry-meta">
            <?php if ('post' == get_post_type()) { // Hide category and tag text for pages on Search ?>
            <div class="entry-meta-category-tag">
                <?php
                    /* translators: used between list items, there is a space after the comma */
                    $categories_list = get_the_category_list(__(', ', 'wmillock'));
                    if (!empty($categories_list)) {
                ?>
                <span class="cat-links">
                    <?php echo bootstrapBasicCategoriesList($categories_list); ?>
                </span>
                <?php } // End if categories ?>
    
                <?php
                    /* translators: used between list items, there is a space after the comma */
                    $tags_list = get_the_tag_list('', __(', ', 'wmillock'));
                    if ($tags_list) {
                ?>
                <span class="tags-links">
                    <?php echo bootstrapBasicTagsList($tags_list); ?>
                </span>
                <?php } // End if $tags_list ?>
            </div><!--.entry-meta-category-tag-->
            <?php } // End if 'post' == get_post_type() ?>
    
            <div class="entry-meta-comment-tools">
                <?php if (! post_password_required() && (comments_open() || '0' != get_comments_number())) { ?>
                <span class="comments-link"><?php bootstrapBasicCommentsPopupLink(); ?></span>
                <?php } //endif; ?>
    
                <?php bootstrapBasicEditPostLink(); ?>
            </div><!--.entry-meta-comment-tools-->
        </footer><!-- .entry-meta -->
    </article><!-- #post-## -->
    I have been advised to change is_search() to is_singular() but that didn't work. I have also tried changing it to is_categories('1') as there are no categories just uncategorized which is 1.

    I assume I am being fundamentally thick here but have been looking at it for hours and am quite frankly sick of it !
     
  2. theshadow2001

    theshadow2001 [DELETE] means [DELETE]

    Joined:
    3 May 2012
    Posts:
    5,284
    Likes Received:
    183
    What happens if you replace is_search() with just True to always run that piece of code?
    ...Or it might be TRUE, or you could put something in like 1 === 1 or some other true value just to test. I've never seen php before so I don't know the exact syntax.
     
    Last edited: 16 Mar 2019
    GaryP likes this.
  3. GaryP

    GaryP RIP Tel

    Joined:
    31 Aug 2009
    Posts:
    5,311
    Likes Received:
    759
    Thanks for reply.

    How would the syntax of that work ? I don't really know how to put that in although I do understnaad the logic !!
     
  4. theshadow2001

    theshadow2001 [DELETE] means [DELETE]

    Joined:
    3 May 2012
    Posts:
    5,284
    Likes Received:
    183
    See the edit above, I've never seen php before. So I'm not sure on they syntax. You could just pull the code out of the whole if else statement and run it that way either.
     
    GaryP likes this.
  5. GaryP

    GaryP RIP Tel

    Joined:
    31 Aug 2009
    Posts:
    5,311
    Likes Received:
    759
    I am sorry, I just don't get it. This is probably why they are getting frustrated with me elsewhere !
     
  6. GaryP

    GaryP RIP Tel

    Joined:
    31 Aug 2009
    Posts:
    5,311
    Likes Received:
    759
    Stone me sorted it. Its the same code as in twentyfourteen theme and found an article about that. added is_home() to if (is_search()) and it worked
     
  7. theshadow2001

    theshadow2001 [DELETE] means [DELETE]

    Joined:
    3 May 2012
    Posts:
    5,284
    Likes Received:
    183

Share This Page