Forum

Thread tagged as: Blog

Duplicate blog post title

I'm new to Perch, but so far loving it and it's quite easy to get a handle on.

I do have one issue on my /blog/post.php page. There are 2 post titles. The top title is coming from <?php perch_blog_post_field(perch_get('s'), 'postTitle'); ?> and the lower one is coming from the blog post itself.

I've been following the videos to get up and running and I added the 'postTitle' as suggested in the video. My question is, how do I get rid of the second post title, which also has a link attribute?

Have I messed something up, or do I need to edit a template? I was reluctant to just start editing things. I'd also like to add that I've searched the forum to see if anyone had a similar issue.

Here are my settings

Perch: 3.1.3, PHP: 7.2.12, MySQL: 10.1.36-MariaDB, with PDO
Server OS: Linux, litespeed
Installed apps: content (3.1.3), assets (3.1.3), categories (3.1.3), perch_blog (5.6.1)
App runtimes: <?php $apps_list = ['perch_blog' ];
PERCH_LOGINPATH: /perch
PERCH_PATH: /home/egginton/public_html/test1.egginton.org/perch
PERCH_CORE: /home/egginton/public_html/test1.egginton.org/perch/core
PERCH_RESFILEPATH: /home/egginton/public_html/test1.egginton.org/perch/resources
Image manipulation: GD Imagick
PHP limits: Max upload 50M, Max POST 50M, Memory: 128M, Total max file upload: 50M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
HTTP_HOST: test1.egginton.org
DOCUMENT_ROOT: /home/egginton/public_html/test1.egginton.org
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Neil Egginton

Neil Egginton 0 points

  • 2 years ago

Can you post the code for the page and the post.html template?

Thanks for replying Clive.

Here is the post.html template:

<article class="h-entry">
    <h1>
        <a href="<perch:blog id="postURL" type="hidden" />" rel="bookmark" class="p-name">
            <perch:blog id="postTitle" type="text" label="Title" required="true" size="xl autowidth" order="1" />
        </a>
    </h1>
    <p class="meta">
        <time class="dt-published" datetime="<perch:blog id="postDateTime" type="date" label="Date" time="true" format="Y-m-d H:i:s" divider-before="Publishing" />">
            <perch:blog id="postDateTime" type="date" time="true" format="%d %B %Y" /> 
        </time>
        <perch:if exists="authorGivenName">
            by <span class="p-author h-card"><perch:blog id="authorGivenName" type="hidden" /> <perch:blog id="authorFamilyName" type="hidden" /></span>
        </perch:if>    
        <perch:categories id="categories" set="blog" label="Categories" display-as="checkboxes">
            <a href="archive.php?cat=<perch:category id="catSlug" type="slug" />" class="p-category">
                <perch:category id="catTitle" type="text" />
            </a>
        </perch:categories>

    </p>
    <perch:if exists="image">
        <div>
            <img src="<perch:blog id="image" type="image" width="320" height="240" crop="true" label="Image" order="4" />" alt="<perch:blog id="postTitle" />" />
        </div>
    </perch:if>
    <div class="description e-content">
        <perch:blog id="postDescHTML" type="textarea" label="Post" order="2" editor="markitup" markdown="true" size="xxl autowidth" required="true" />
    </div>
</article>

<perch:blog id="excerpt" type="textarea" label="Excerpt" markdown="true" order="3" suppress="true" size="s" />
<perch:blog id="image" type="image" width="50" height="50" crop="true" suppress="true" />

And here is the page code:

<!doctype html>
<html class="no-js">
<head>
    <meta charset="utf-8" />
    <meta http-equiv="x-ua-compatible" content="ie=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes" />

    <title>Post | Test1</title>

    <meta name="theme-version" content="1.7.4" />
    <meta name="foundation-version" content="5.5.3" />
    <meta name="modernizr-version" content="2.8.3" />


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="robots" content="index, follow" />
        <meta name="generator" content="RapidWeaver" />


    <link rel="stylesheet" type="text/css" media="all" href="../rw_common/themes/foundation/consolidated.css?rwcache=563879324" />

    <script>var foundation={};</script>
    <script>function loadCSS(a,b,c){"use strict";var d=window.document.createElement("link"),e=b||window.document.getElementsByTagName("script")[0],f=window.document.styleSheets;return d.rel="stylesheet",d.href=a,d.media="only x",e.parentNode.insertBefore(d,e),d.onloadcssdefined=function(a){for(var b,c=0;c<f.length;c++)f[c].href&&f[c].href===d.href&&(b=!0);b?a():setTimeout(function(){d.onloadcssdefined(a)})},d.onloadcssdefined(function(){d.media=c||"all"}),d}</script>



            <link rel='stylesheet' type='text/css' media='all' href='../rw_common/plugins/stacks/stacks.css?rwcache=563879324' />
        <link rel='stylesheet' type='text/css' media='all' href='post_files/stacks_page_page6.css?rwcache=563879324' />
        <script type='text/javascript' charset='utf-8' src='../rw_common/plugins/stacks/jquery-2.2.4.min.js?rwcache=563879324'></script>

        <link rel="stylesheet" href="../rw_common/plugins/stacks/font-awesome.min.css?rwcache=563879324">


        <script type='text/javascript' charset='utf-8' src='post_files/stacks_page_page6.js?rwcache=563879324'></script>
        <meta name="formatter" content="Stacks v3.6.4 (4202)" >
        <meta class="stacks3 stack version" id="com.joeworkman.stacks.foundation.header" name="Header" content="1.7.16">
        <meta class="stacks3 stack version" id="com.joeworkman.stacks.foundation.topbar.s3" name="Top Bar" content="1.7.16">
        <meta class="stacks3 stack version" id="com.joeworkman.stacks.foundation.1col.s3" name="1 Column Foundation" content="1.7.16">
        <meta class="stacks3 stack version" id="com.joeworkman.stacks.foundation.topbar.dropzone" name="Top Bar Dropzone" content="1.7.16">
        <meta class="stacks3 stack version" id="com.joeworkman.stacks.foundation.styles.s3" name=" Site Styles" content="1.7.16">




    <script>var jQuery=stacks.jQuery,$=jQuery;</script>

</head>

<body class="antialiased">

<div id="foundation-loader"></div>


<div id='stacks_out_1_page6' class='stacks_top'><div id='stacks_in_1_page6' class=''>  <!--[if lt IE 9]><meta http-equiv="refresh" content="0; url="><![endif]-->   

<div id='stacks_out_32_page6' class='stacks_out'><div id='stacks_in_32_page6' class='stacks_in com_joeworkman_stacks_foundation_topbar_s3_stack'>

<!-- Foundation Top Bar Menu stake-nomin -->


<div class="top-bar-wrapper full-width     contain-to-grid matchPadding solid    submenuIndicator menu-align-right zone-align-left">
    <nav class="top-bar" data-topbar data-options="is_hover:true;custom_back_text:true;back_text:Back;mobile_show_parent_link:true;scrolltop:false;" role="navigation">
        <ul class="title-area title-area-site-setup">
            <li class="name ">

                    <a href="https://test1.egginton.org/">

                            <span class=""></span>


                            <h1 class="site-title font-family-h1 ">
                                Test1
                                <small class="site-slogan ">Changing the world, one site at a time&hellip;</small>
                            </h1>

                    </a>



            </li>
            <li class="toggle-topbar menu-icon">
                <a href="#">
                    <span>Menu</span>
                </a>
            </li>
        </ul>

        <section class="top-bar-section  menu-rw">







    <ul class="menu dropdown" role="navigation"><li class="has-dropdown" role="menuitem"><a href="../" rel="">One</a></li><li class="has-dropdown" role="menuitem"><a href="../two/" rel="">Two</a></li><li class="has-dropdown" role="menuitem"><a href="../three/" rel="">Three</a></li><li class="has-dropdown" role="menuitem"><a href="../four/" rel="">Four</a></li><li class="has-dropdown" role="menuitem"><a href="../blog/" rel="">Perch Blog</a></li><li class="active has-dropdown" role="menuitem"><a href="post.php">Post</a></li><li class="has-dropdown" role="menuitem"><a href="../page/" rel="">Stats-admin</a></li></ul>










        </section>
    </nav>
</div>



</div></div><div id='stacks_out_69_page6' class='stacks_out'><div id='stacks_in_69_page6' class='stacks_in com_joeworkman_stacks_foundation_1col_s3_stack'>

<div class='row   max-custom     '
><div class='columns small-12   '> <div id='stacks_out_70_page6' class='stacks_out'><div id='stacks_in_70_page6' class='stacks_in com_joeworkman_stacks_foundation_header_stack'>

<h1 class="text-left     " >Test Blog</h1>

</div></div><div id='stacks_out_76_page6' class='stacks_out'><div id='stacks_in_76_page6' class='stacks_in html_stack'><article class="h-entry">
    <h1>
        <a href="/blog/post.php?s=2018-11-14-test-blog" rel="bookmark" class="p-name">
            Test Blog
        </a>
    </h1>
    <p class="meta">
        <time class="dt-published" datetime="2018-11-14 07:32:00">
            14 November 2018 
        </time>

            by <span class="p-author h-card">Neil Egginton</span>


            <a href="archive.php?cat=test" class="p-category">
                Test
            </a>


    </p>

        <div>
            <img src="/perch/resources/placeholder-w320h240.png" alt="Test Blog" />
        </div>

    <div class="description e-content">
        <p>When people start a WordPress website or blog, they generally don’t have a lot of information about the best way to begin. Most people start off on their own or listen to bad advice from “WordPress experts” or a friend who has a website and thinks that qualifies them to give you advice.</p>
<p>So, what are the biggest mistakes people make with WordPress?</p>
<p>Designing for yourself
One of the biggest mistakes of Web design is designing for yourself instead of your users.</p>
<p>Your website is a blank canvas, but don’t be tempted to put things on it that aren’t relevant to your visitors. You might like a flowery background image; your visitors probably don’t. You might also like different coloured texts all over the place, but that’s so 90s.</p>
<p>Choosing a bad theme
This is a big one. But, what is a bad theme? Every WordPress theme is coded (built) with HTML, CSS, Javascript, PHP and more. If the person coding the theme isn’t a professional coder, the theme will have errors, even though it might look fine.</p>
<p>Your website might look great to you and your visitors, but Google and other search engines see things differently. They see the raw code (HTML etc.) that’s lurking behind the scenes. Crappy coding can also leave your site more vulnerable to hackers and malware.</p>
<p>You could build your new website thinking everything looks good and performs well, but you could be very wrong. That’s why I only use and recommend WordPress themes from DIY Themes (Thesis) and Studiopress (Genesis). I’m not saying there aren’t some really good themes out there.</p>
<p>And, if you’re looking for a good free theme, Generate Press seems to fit the bill. There are also some other very popular themes that aren’t badly coded, but are bloated with functions and extras that can slow down your site.</p>
<p>Some of the most popular themes on the market at the moment are Avada (over 260,000 sales), X Theme (over 120,000 sales) and Listify if you want to build a directory.</p>
<p>Filling it with unnecessary stuff
When people first install WordPress, they probably see a lot of Whitespace; lots of room to put stuff. When creating your site, don’t be tempted to fill every space with a widget, photos, sign up forms, pop ups and other distractions. People want to buy stuff from you or learn something.</p>
<p>Make sure that what you’re selling, promoting, teaching or saying is very easy to find. Don’t clutter your site or blog with distractions.</p>
<p>Installing too many plugins
How many plugins is too many?</p>
<p>One more than you need is the simple answer.</p>
<p>I once worked on a client site with 55 WordPress plugins installed on it. I couldn’t believe what I was seeing. The site wasn’t using half of them and 10 or more weren’t necessary.</p>
<p>Too many plugins will slow your site down, and fill it with clutter. Before installing a plugin, ask yourself if it’s really necessary. Is it useful for your users? What value will it add?</p>
<p>Installing bad plugins
When you do decide that a plugin is necessary, it’s important to install the right one. There are thousands to choose from, but many of them are no longer updated. Plugins need to be updated to keep up with the latest WordPress version.</p>
<p>There are a few things you can look for to check if a plugin is current and can be trusted.</p>
<p>Is it up-to-date?
When was the last time the plugin updated?
Is is compatible?
WordPress plugins need to be tested on the current version of WordPress to make sure it’s compatible. If it hasn’t been tested on the current version, give it a wide berth.
How popular is it?
Its popularity will help you decide if it’s any good. Plugins that have been downloaded thousands of times should be good.
Not optimising your website
If you get all of the above right, you’re nearly there. But we still need to make sure your site performs well.</p>
<p>Is it fast? If it takes over 2 seconds to load, it’s not.</p>
<p>Are large images slowing it down? Uploading images without optimising them will slow your site down and also use more bandwidth on your web host.</p>
<p>Using cheap shared hosting</p>
<p>When you start out, it’s not necessarily a bad thing to go cheap. Why spend big bucks if you’re just getting started?</p>
<p>If you go cheap, go with Bluehost or Hostgator. If you’re based in the UK, Guru Cloud Hosting is highly recommended.</p>
<p>You can do everything right with WordPress, but pick a crap host and you’ll lose.</p>
<p>Other things to consider</p>
<p>Does your site use SSL?
SSL? Check!</p>
<p>You can see the Green padlock in the browser. That means this site uses encryption. Google wants you to do the same.</p>
<p>Are you mobile friendly?
This goes without saying really.</p>
<p>The world is going mobile, so if your site isn’t ready it will lose out. Google has changed their search engine to a mobile first model, which means that websites that don’t work perfectly on smartphones and tablets might move down the rankings.</p>
    </div>
</article>


</div></div></div></div>

</div></div></div></div>



<script data-cfasync="true" src="../rw_common/themes/foundation/foundation.min.js?rwcache=563879324"></script>


</body>
</html>

Thanks

By page code, I actually meant the source code not the output. No problem though. You will need to edit the page's code to remove the duplicate title, presumably that's the code that generates this <h1 class="text-left " >Test Blog</h1>. You say in your first post that this is generated by <?php perch_blog_post_field(perch_get('s'), 'postTitle'); ?>. You won't need that if you are using the post.html template to display the post.

Thanks again Clive for your reply.

It makes sense to remove the <?php perch_blog_post_field(perch_get('s'), 'postTitle'); ?> part as it's creating the duplicate, but the post title that's part of the post.html template is a link. I can understand it being a link on the main blog page, but once I'm on the post's post.php page I'd expect it not to be a link. Is there a way to stop that?

Thanks

You can edit the post.html template or create your own template to display blog posts. If you do this, there's information ("Editing Templates") here https://docs.grabaperch.com/templates/apps/blog/ about the location of new templates.

Thanks Clive