• Resolved trojanloy

    (@trojanloy)


    Dear Admins: Please do not delete this support topic. It is a legit support question, and I have the code portion working properly now. Thank you very much. [email protected]

    Hi,

    I have a Page, with a Page Template, set up to display certain posts using a Custom SELECT Query. It works like a charm, except for one thing: it ignores the <!--more--> tags on my posts, and displays the entirety of every post.

    I assume this is because my Custom Query Page, although it contains many posts, is not considered a “non-single/non-permalink post page,” as described here in the codex.

    I tried tinkering with the settings described in Customizing the Read More, but to no avail. Those seem to simply adjust the formatting of the “Read More” link; my problem is that the link is not appearing at all.

    Is there any way to “force” the “Read More” link to appear, even though it is technically on a single “Page” (albeit a Page that is calling a Page Template that is using a Custom Select Query to loop through thousands of posts)?

    To see this problem in action, go to https://www.brendanloy.com/wp/non-sports/ and compare the post “More on Dermot O’Reilly” to the way that same post appears on https://www.brendanloy.com/”>my Main Index page.

    In case it helps, here is the Page Template for the Custom Query Page(s) in question:

    [Moderated: Too much code. Please consider using a pastebin such as https://wordpress.pastebin.ca/ and posting back here with the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Dear Admins: Please do not delete this support topic. It is a legit support question, and I have the code portion working properly now. Thank you very much. [email protected]

    It wasn’t deleted. The 7 times you posted were all in the Akismet possible spam queue.

    By diligently searching you can find several references to code lines that help you to set the “is_page” to FALSE in your query > and letting you to do what you want.

    Thread Starter trojanloy

    (@trojanloy)

    HandySolo, thank you, and I apologize. I actually eventually guessed that it was probably a technical issue, but only after posting the above. To use a Wikipedia term, I shouldn’t have “assumed bad faith” … my mistake.

    (Also, I don’t think I deliberately tried posting it 7 times – I’m pretty sure it was 4, and the first two, I thought maybe had been deleted because I had the code messed up. If there were 7 attempts, maybe there was some glitch whereby it registered twice when I clicked the Submit button… dunno.)

    Moshu, thank you! I had done some searching, but hadn’t thought of looking at is_page. I’ll poke around and see what I come up with, and will come back here if I can’t find what I’m looking for.

    Thread Starter trojanloy

    (@trojanloy)

    P.S. to HandySolo: Is there any way to modify your Akismet setup, so that readers would get a message indicating that their support request has been sent into the queue by an automated spam blocker, and that if it’s not spam, the admins will approve it shortly? I know such a message would have prevented me from being so impatient – it was the frustration of not have any clue what was happening that caused me to post repeatedly and append my annoyed note to the admins.

    If that’s not technically possible, maybe even a general message to all posters that appears below the Submit button that says something like, “Occasionally, new support topic submissions are held as possible spam until they can be approved by an administrator. If you topic does not immediately appear, this is probably why. Please be patient and do not re-post your topic. If it does not appear within _______, then you may want to contact ______ to check on the status,” blah blah blah. Something like that.

    Just a humble suggestion. ??

    “We” = the volunteer helpers in the Support Forum, have as much power about the Akismet setup… as yourself ??
    Nor can we modify the ‘messages’ displayed.
    Also, there is no guarantee that any moderator will come around in X minutes to check the posts killed by Akismet.

    Sorry, I fully understand the rationale behind your suggestion, and just wanted to let you know why it is more complicated than you think…

    Thread Starter trojanloy

    (@trojanloy)

    Heh, I understand.

    Thread Starter trojanloy

    (@trojanloy)

    WOOHOO! I’ve solved the problem.

    Setting is_page = FALSE didn’t work, for whatever reason, but searching for how to do that led me to an alternate solution, discussed in this thread: adding <?php $more = 0; ?> to my template. That did the trick!

    For the sake of future searchers, here is what the relevant portion of my code looks like:

    <?php $pageposts = $wpdb->get_results(\"SELECT *
    FROM $wpdb->posts
    WHERE ID NOT IN
    (SELECT post_id from $wpdb->post2cat
    WHERE category_id = ANY(SELECT cat_ID
    FROM $wpdb->categories WHERE cat_ID = 369
    OR category_parent = 369 OR category_parent =
    ANY(SELECT  cat_ID FROM $wpdb->categories
    WHERE category_parent = 369) OR category_parent =
    ANY(SELECT cat_ID FROM $wpdb->categories
    WHERE category_parent = ANY(SELECT  cat_ID
    FROM $wpdb->categories WHERE category_parent = 369))))
    AND $wpdb->posts.post_date < (NOW() + INTERVAL 2 HOUR)
    AND $wpdb->posts.post_status = 'publish'
    AND $wpdb->posts.post_type = 'post'
    ORDER BY $wpdb->posts.post_date
    DESC LIMIT $offset, $perpage\", OBJECT);
    ?>
     <?php if ($pageposts): ?>
      <?php foreach ($pageposts as $post): ?>
        <?php setup_postdata($post); ?>
    
    <?php $more = 0; ?>

    Ignore the backslash(es) before the quotation marks… they don’t belong there, but I can’t figure out how to get rid of them above.

    Thanks, moshu, for pointing me in the right direction!

    As I was experiencing the same problem (can get the ‘more’ tag to work in a page with multiple loops), your post gives me exactly the solution I was looking for!

    Thanks a lot ??

    Thanks, <?php $more = 0; ?> solved my problem too!

    one for the bookmarks. Thank you!

    I always use this within a second loop on pages that contain news headlines in the sidebar or on the page.

    <ul class="nolist">
    	<?php
    	 global $post;
    	 $myposts = get_posts('numberposts=5&category=3');
    	 foreach($myposts as $post) :
    	 setup_postdata($post);
    	 $more = 0;
    	?>
    	<li><a href="<?php the_permalink(); ?>" title="Lees verder: <?php the_title_attribute(); ?>"><?php the_title(); ?></a><br />
    	<small>&bull; Geplaatst op <?php the_time('d-m-Y') ?></small></li>
    	<?php endforeach; ?>
    </ul>
Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Force “Read More” to appear on custom Page?’ is closed to new replies.