Forum
Blog posts not showing on Home page
Hi Drew,
Since updating to v3 and subsequently the latest version, the blog posts are nolonger being displayed when using the following
php perch_blog_custom([
'template' => 'promo.html',
'count' => '3',
'sort' => 'postDateTime',
'sort-order' => 'DESC',
'filter'=>array(
array(
'filter' => 'postDateTime',
'match' => 'gte',
'value' => date('Y-m-d H:i:s', strtotime('- 3 MONTHS')),
),
array(
'filter'=>'promoinc',
'match'=>'eq',
'value'=>1,
),
)
]); ?>
I have checked to see when the client last posted and it was a couple of times in May. so there should be atleast 2 out of 3 posts showing.
Any thoughs much appreciated.
Perch: 3.0.8, PHP: 7.0.17, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (3.0.8), assets (3.0.8), categories (3.0.8), perch_blog (5.5.1), perch_forms (1.9), perch_shop_orders (1.2.2), perch_shop_products (1.2.2), perch_shop (1.2.2), perch_comments (1.2.1), perch_members (1.6.2), perch_backup (1.2), perch_mailchimp (3.1), perch_twitter (3.7)
App runtimes: <?php $apps_list = array( 'perch_blog', 'perch_comments', 'perch_forms', 'perch_mailchimp', //'perch_twitter', 'perch_members', 'perch_shop', );
PERCH_LOGINPATH: /admin
PERCH_PATH: /home/sites/courtneyandco.uk/public_html/admin
PERCH_CORE: /home/sites/courtneyandco.uk/public_html/admin/core
PERCH_RESFILEPATH: /home/sites/courtneyandco.uk/public_html/admin/resources
Image manipulation: GD
PHP limits: Max upload 64M, Max POST 8M, Memory: 128M, Total max file upload: 8M
F1: 0c66c2e1f82f9e0b7617b2cb8270f2c7
Resource folder writeable: Yes
HTTP_HOST: courtneyandco.uk
DOCUMENT_ROOT: /home/sites/courtneyandco.uk/public_html/
REQUEST_URI: /admin/core/settings/diagnostics/
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
What does the debug output?
The query isn't returning any posts.
What steps have you followed to debug it? Have you broken the request down and tried building it back up?
Hi Drew, Three blog posts are displayed if I strip out the filtering so the issue must be how I've set that up. have I written the filtrer arrays correctly to achieve the intention below?
Display the 3 newest posts (that their "promoinc" field checked OK in the admin) in descending order made in the last three months.
You may be being afflicted by the funny group by issue for multiple filters.
Try this and see if it gives you what you're after:
Hi Duncan (Drew),
That's seems to have done the trick! Thank you. I've changed the code in the following way see below… as I'm a designer rather than a programmer is this the correct way of doing this?
I think you probably only need the one at the bottom (the last one)
I thought that had fixed it but it hasn't. I'd left in a stripped down perch_blog_custom call without the filtering which works in that it displays items just not necessarily the ones I want.
Which version did you upgrade Blog from?
Good question. I'll see if I can figure it out. However I'm pretty good at jumping on new updates so on both sites that this problem is occuring blog would not have been older than 4.5.4 or possible 4.5.3 but most likely it would have been version 4.6
When you logged into Blog did it run through migrating your posts?
Not that I recall
I'm pretty sure that I replaced the core in the normal way, replaced the blog app, uploaded everything, logged into the admin, received the updated noticifcation and that was it.
So you've not visited the Blog app in the control panel since updating?
On both sites that are suffering with the same issue, I've visited the blog app, primarily to check that the last post was within the last 3 months (as that was my initial thought as to why nothing was showing.) I don't recall seeing it/or being told that it was migrating my posts. I haven't tried adding a new post, would that automatically be in the right "format" (i.e. not need migrating)? If so I'll happily create new posts to replace the old ones.
Both sites? Are they on the same server?
I'll check
They are on separate servers.
Is the code the same on both? I'm confused what we're dealing with now.
Sorry Drew… Yes, I reused it on another site, as I thought it was pretty cool.