• I have an already existing static website for a client https://www.rrfp.net

    They wanted the ability to have an easily updateable news page. They wanted something very simple, no comments, no calendar. They wanted (a) the news page to have the title and excerpt and date from the last 5 posts. And then they wanted (b) each news item excerpt to link to the whole news item on its own page. They also wanted (c) an archive view where someone could browse all of the news item titles at once.

    I have the first part (a) down https://rrfp.net/news.php

    My only problem with that page is that the_excerpt includes the […] at the end. I have added an additional link “Read on…” that points to the permalink. However if there was a way to edit or link or remove the […] that the_excerpt tags on to the end…

    My next problem is in regards to item (b). The permalink points to the default template and has extra stuff like comments, and category, trackback info at the bottom. I tried editing the index.php, single.php, and archive.php files in the template directory, but to no avail. I would like the permalink page to look like this https://rrfp.net/blog/perma.php, keeping with the navigation and style of the whole site. However, I have no idea how to go about making this happen.

    I haven’t started working on (c) the archives page. However, I do not foresee having difficulties with that. I’d probably just do the same thing I did with (a) only leave out the_excerpt tag, and set numberposts to a really high number or infinity if possible.

    Thanks for your time.

    a.

Viewing 4 replies - 1 through 4 (of 4 total)
  • (a): There are a few ways you can go about this. One is to edit the source directly and remove the ellipsis from the excerpt text. This would be done in functions-formatting.php ( wp-includes/ directory). There you’ll find the the wp_trim_excerpt function (around line 700). Removing or commmenting out this statement:

    if (count($words) > $excerpt_length) {
        array_pop($words);
        array_push($words, '[...]');
        $text = implode(' ', $words);
    }

    will remove the ellipsis.

    Another option is to copy the function into your template, rename it to something like my_excerpt(), make your edit, and call that in your template instead of the_excerpt(). Benefits to this are A. you don’t need to keep track of code changes when upgrading WordPress, and B. it won’t place the excerpt in a paragraph () element, so using the excerpt as a link won’t generate invalid XHTML. You’re also are free to customize the output any way you want.

    (b): single.php is the permalink template for posts, so you want to make any changes to the layout for a permalink page there. To remove comments, look for:

    <?php comments_template(); ?>

    and remove that. The rest are displayed through their respective template tags, categories through the_category(), etc.

    Note that there’s nothing stopping you from using your current layout as a theme, incorporating only those WordPress elements (such as The Loop) into it that you require. It would certainly be easier than trying to modify the default theme’s templates to look like your present design. You can find information on the process of creating a theme here:

    https://codex.www.ads-software.com/Theme_Development

    Thread Starter andrew_c

    (@andrew_c)

    I’m a little confused, you say “Another option is to copy the function into your template”. By template, in this case you mean my news.php file? And where would the copied and edited funtion go, somewhere in the header?

    I understand the rest about calling my_excerpt() instead of the_excerpt().

    I also attempted to make a very simple theme to start with, then messing around with that but I could not even get the new theme to show up in the admin presentation view. I started off with a copy of the kubrick’s index.php and a copy of style.css with the header’s info changed. I uploaded them into /wp-content/themes/rrfp/ and double checked the permissions, however this theme still does not show up.

    Thanks a whole lot for your help. I really appreaceate you taking time to help walk me through this.

    “By template, in this case you mean my news.php file? “

    Yep. A WordPress template is no different than a plugin or core source file in this regard (the real difference is how they’re included in the whole process). The function just needs to reside between <?php and ?> tags in your news.php, although having it come before you actually call it is important. I tend to keep specialized or modified code in a separate file with my theme, and include this file on the first line of my header.php. Other options are to set it up in the my-hacks.php file, or create a plugin around the function(s).

    “I also attempted to make a very simple theme to start with, then messing around with that but I could not even get the new theme to show up in the admin presentation view. I started off with a copy of the kubrick’s index.php and a copy of style.css

    I thought you were starting off with a very simple theme… :)

    Thread Starter andrew_c

    (@andrew_c)

    Ah ok, that all makes sense now.

    Here is my next problem. I have downloaded a theme called basic https://www.visual-assault.org/projects/wp_theme-basic/. When I upload it into the theme directory at the rrfp.net site, I cannot get it to show up in the Presentation view of the admin panel. However, when I upload it to my personal webpage, it works fine. What could be wrong? If I contact the client’s server, what do I need to tell them?

    This may be another piece of the puzzle. When I delete all the .php files from the kubrick theme’s directory, it does not change the look of the blog whatsoever. However, if I mess with the style sheet, I can get things like color and type and position to change. However, nothing I do can change the tags and page structure (which is very strange considering I deleted the files completely).

    I think it may have something to do with them having a central install of wordpress for all of the pages they host??

    Thanks again for your time!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Editing permalink theme’ is closed to new replies.