WordPress.org

Ready to get started?Download WordPress

Forums

Trying to figure out why this code does not work (12 posts)

  1. json21
    Member
    Posted 1 year ago #

    I was able to get a code to display a sticky post on the bottom of the page, with help of one of the moderators of this forum, but for some reason I am not able to apply it to a newer theme (Twenty Twelve)

    I am using a child theme, and the original topic can be found here:
    http://wordpress.org/support/topic/how-to-build-a-custom-query-in-twenty-eleven

    The functions.php looks like this: http://pastebin.com/vM8j047H

    And this is what I came up with as far as index.php:
    http://pastebin.com/FdG9vqAT

    I checked everything several times, and it looks correct to me, but I am not sure why it doesn't work.

    Thank you in advance for any info.

  2. keesiemeijer
    moderator
    Posted 1 year ago #

    I just tested your code on Twenty Twelve (in a child theme) and it works for me. Are you sure the child theme is activated? Do you see a sticky post at the bottom of the first page?

  3. json21
    Member
    Posted 1 year ago #

    I am showing a sticky post on the top, and eight regular posts underneath it, so it is nine posts total on the main page. Settings -> Reading -> Blog pages show at most is set to 10.

    I am basing it on a child theme, and I use the following files:

    style.css
    index.php
    functions.php

    The contents of the files (directly from the server) are here:

    http://pastebin.com/bJGCyD4t

    # # #

    I will be probably working on modifying 20 different wordpress thems, and all of them need to display a single sticky post on the bottom of the main page. Unfortunately there is no plugin that achieves this task.

  4. keesiemeijer
    moderator
    Posted 1 year ago #

    What is it exactly that is not working? Do you see a sticky post at the bottom of the first page? Is the pagination not working? How do you show a sticky on top of the first page?

  5. json21
    Member
    Posted 1 year ago #

    The sticky is on the top instead of on the bottom, and there is 8 + 1 posts on the page, instead of 10.

  6. keesiemeijer
    moderator
    Posted 1 year ago #

    That's strange, I tested again with the code from your server in my child theme and it works (sticky at the bottom of the home page).

    Can you try:

    - flushing any caching plugins you might be running, as well as server and/or browser caches.

    - deactivating all plugins to see if this resolves the problem? If this works, re-activate the plugins one by one until you find the problematic plugin(s).

  7. json21
    Member
    Posted 1 year ago #

    I created a brand new WordPress installation (the newest version, 3.5.1), and Twenty Twelve 1.1 was included by default. I did not install anything else. This means I dont have any plugin, WordPress cache, or anything like that.

    I uploaded twenty_twelve_sticky_new over the ftp (exactly the same files that I included in pastebin in the previous post), and I display sticky on the top (as the first post), and 8 posts underneath it.

    The website is located at http://blog.gloryhole-porn.net/ (no adult content)

  8. keesiemeijer
    moderator
    Posted 1 year ago #

    When I look at the source code the "This is Sticky" post doesn't have a class "sticky". Are you sure you made it a sticky post?

    // your "This is Sticky" post":
    <article id="post-45" class="post-45 post type-post status-publish format-standard hentry category-uncategorized">
    
    // sticky post on my test site:
    <article id="post-68" class="post-68 post type-post status-publish format-standard sticky hentry category-uncategorized">
  9. json21
    Member
    Posted 1 year ago #

    Thank you. That's it. Everything is working fine.

  10. json21
    Member
    Posted 1 year ago #

    I spent some time reading on how wordpress code works (The Loop, template files, template tags), and moved on to another theme, called Blaskan (http://wordpress.org/extend/themes/blaskan).

    I modified the index.php and loop.php of the theme, to incorporate the "display sticky on the bottom" code, but I get a sticky on the top and on the bottom of the page at the same time (eleven posts total).

    I've been trying to figure out what's going on for a while, but I am not able to find a solution.

    The code for the current index.php, and loop.php is here:

    http://pastebin.com/3sptyETR

    (It is different from the original structure, as I inserted the main loop into index.php <it is originally in loop.php>, and modified the loop.php to include only the formatting of the posts)

    If it would be needed, I included the orginal Blaskan code for these two files here:

    http://pastebin.com/2Uw1nwqs

    Thank you in advance for any info.

  11. json21
    Member
    Posted 1 year ago #

    I changed the published date to something in the past, and it is still displaying on the very top (and on the bottom), so it does not have anything to do with the fact that it is the most recent post etc. It is on the top because it is set to sticky (I want it on the bottom only).

  12. json21
    Member
    Posted 1 year ago #

    I was able to get it to work. I forgot about making changes to functions.php file.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.