Forum Replies Created

Viewing 15 replies - 16 through 30 (of 65 total)
  • Thread Starter ggg377

    (@ggg377)

    For general notice, I set up a sample site here: https://goldenred.web44.net

    Thanks for replying dotnordic. I think that’s a good suggestion and that’s probably how I’m going to approach this. I ran into some issues with coding. When I used the following code, the h1 text title shows up over the logo image:

    <?php
    if ( is_front_page() ) {?>
    <h1 id="primary-title"><a href="<?php bloginfo('url'); ?>">my title</a></h1>
    <?php
    } else {
    ?>
    <h2 id="secondary-title"><a href="<?php bloginfo('url'); ?>">my title</a></h2>
    <?php
    }?>
    #primary-title {
    margin: 7px 0 0 0; padding: 0;
    width: 141px;
    height: 31px;
    float: left;
    clear:both;
    display: block;
    }
    
    #primary-title a {
    display: block;
    width: 141px;
    height: 31px;
        background-image: url('https://goldenred.web44.net/wp-content/uploads/2013/02/yawn.jpg');
    }
    
    #primary-title a:hover {
    display: block;
    width: 141px;
    height: 31px;
        background-image: url('https://goldenred.web44.net/wp-content/uploads/2013/02/yawnhover.jpg');
    }
    
    #secondary-title {
    margin: 7px 0 0 0; padding: 0;
    width: 141px;
    height: 31px;
    float: left;
    clear:both;
    display: block;
    }
    
    #secondary-title a {
    display: block;
    width: 141px;
    height: 31px;
        background-image: url('https://goldenred.web44.net/wp-content/uploads/2013/02/yawn.jpg');
    }
    
    #secondary-title a:hover {
    display: block;
    width: 141px;
    height: 31px;
        background-image: url('https://goldenred.web44.net/wp-content/uploads/2013/02/yawnhover.jpg');
    }

    The CSS also seems kind of inefficient, because it uses the same code twice. I think it should be possible to do it without the h1 title (“my title” in the code snippet) showing though, I’ve seen it on many popular sites like yoast, hongkiat etc, just without the hover effect. If anyone has ideas on how to fix the code I would be glad to hear them.

    The problem is displayed in the sample site.

    I have the same issue. Front page purging is enabled from Purge Policy.

    Thread Starter ggg377

    (@ggg377)

    Hey keesiemeijer, sorry for the delay. I reverted back to the old version. The category navigation does work if there’s more posts (however it does show duplicate labels and the number of dates on a page varies randomly). Kind of a shame the more optimized piece of code went to waste, but the code I have does do the job for now ??

    Thread Starter ggg377

    (@ggg377)

    Edit: the category archives aren’t scrolling in this code. For example when I open the “Uncategorized” archive by clicking on uncategorized in a post (in the sample site), then the newer posts show, the older don’t and there is no navigation and therefore no scrolling. I might look into this myself later, but if it’s a quick fix, I’ll be happy to hear your suggestions. I’ll need this functionality and the previous script does that for me.

    Thread Starter ggg377

    (@ggg377)

    Deleting that line fixed the string and pagination issues. It seems to be perfect now. Cheers!

    What happened to the original code you proposed anyway? Is there anything I could do to help you figure it out or is it not worth getting into?

    Thread Starter ggg377

    (@ggg377)

    I tested the code. Prioritizing seems to work correctly now, but a weird string of numbers now appears in the header of the page. Also pagination seems to work differently, but I’m not sure.

    functions.php: https://pastebin.com/BTTeGfuw
    live page: https://goldenred.web44.net

    edit: new posts are loaded as soon as I’m halfway into “Today”. This doesn’t happen with my previous code (posts are loaded after scrolling through 4 dates).

    Thread Starter ggg377

    (@ggg377)

    I added a bunch of different posts to Today with different categories to test the code. The posts go from 1-26 in chronological order (from 1 oldest to 26 newest).

    It seems that in general if a post is only in the category “test”, it always gets moved to the top. However there’s a “test” post on February 2 that didn’t get moved to the top. Usually if a post is in multiple categories it doesn’t get moved to the top, but sometimes they still do (1 post under Today and 1 under February 3). Also what I noticed is that when I added test posts, the post that had multiple categories, but was on top for whatever reason, changed. At one point it was a post which had 3 categories in addition to “test” and then it changed to a post, which only had “Uncategorized” in addition to “test”. Once again, I wasn’t able to notice a correlation.

    No posts seem to be missing.

    You can check out the test posts until February 3. Everything is in chronological order from oldest to newest.

    Thread Starter ggg377

    (@ggg377)

    Hey keesiemeijer, thanks for the code. I implemented it, but it doesn’t seem to work properly. Some sorting does take place, but that is very occasional and I couldn’t find a pattern why some posts got moved. Moving of posts from the default arrangement was very rare.

    functions.php: https://pastebin.com/P1LPxmdH
    index.php (switched the code I had for pagination for this):

    <?php
    $dates_per_page = 4;
    get_index_pagination_nav( 'nav-below', $dates_per_page);
    ?>

    I also left the bugged implementation up at the example site.

    It would definitely be cooler to use a more optimized code, so I’m all in as far as co-operation ??

    Thread Starter ggg377

    (@ggg377)

    I’m glad it was a fun challenge. Thanks for pointing out the potential improvement for non-javascript users. I’ll look into stylizing the links. On another note, I’ve tested the loop a bit now and so far it seems perfect. Thank you so much!

    Thread Starter ggg377

    (@ggg377)

    That did it keesiemeijer. I don’t have any more questions. Thank you for your help and co-operation. I’ll try to make it up in time. I hope solving this issue was at least somewhat fun and interesting for you.

    ggg377

    Thread Starter ggg377

    (@ggg377)

    Placing that code within this function resulted in a nasty syntax error no matter how I did it:

    function twentytwelve_content_nav( $html_id ) {code here}

    In the end for me it’s not that important to use twentytwelve’s function, but to get working selectors for #content nav and #content nav a. If that could be done easier within your function, while getting the same functionality then that would be great too. However if I placed your code wrong, then repairing that would be just fine.

    Thread Starter ggg377

    (@ggg377)

    It worked, which also means this thread has reached its conclusion. You definitely helped solve a complex issue and I am most thankful for that. Your skills are impressive. Instead of just showering you with praise though, I’ll try to help people out on the forum instead at times and I’ll also try to understand the code, which you wrote, better. This was such a huge help, that it deserves more than just a thank you in my opinion. I hope this knowledge will be useful for other WordPress users as well.

    As a last thing, I figured if you have an idea how to wrap the pagination function in nav tags? I actually used twentytwelve’s pagination functions before, which looked like this:

    index.php:

    <?php twentytwelve_content_nav( 'nav-below' ); ?>

    functions.php:

    if ( ! function_exists( 'twentytwelve_content_nav' ) ) :
    /**
     * Displays navigation to next/previous pages when applicable.
     *
     * @since Twenty Twelve 1.0
     */
    function twentytwelve_content_nav( $html_id ) {
    	global $wp_query;
    
    	$html_id = esc_attr( $html_id );
    
    	if ( $wp_query->max_num_pages > 1 ) : ?>
    		<nav id="<?php echo $html_id; ?>" class="navigation" role="navigation">
    			<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3>
    			<div class="nav-previous alignleft"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentytwelve' ) ); ?></div>
    			<div class="nav-next alignright"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?></div>
    		</nav><!-- #<?php echo $html_id; ?> .navigation -->
    	<?php endif;
    }
    endif;

    The important thing was that with this implementation, I received selectors like this: navigation (section) selector: #content nav, next (page) selector: #content nav a. I tried wrapping the functions in your code in nav tags, but it didn’t work:

    function next_date_link( $dates_per_page = 10, $label = 'Next Page' ){
                    return previous_date_link( $dates_per_page, $label, false );
            }
    
            function previous_date_link( $dates_per_page = 10, $label = 'Previous Page', $prev = true ){
    
                    $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
    
                    if ( $prev ) {
    
                            $count = (($paged -1) * $dates_per_page) + $dates_per_page;
                            $limit = ' LIMIT ' . $count . ', 1';
    
                    } else {
    
                            $count = (($paged -1) * $dates_per_page)-1;
    
                            if ( ($count+1) < $dates_per_page )
                                    return '';
    
                            $limit = ' LIMIT ' . $count . ', 1';
    
                    }

    Anyway you can leave this for me to figure out. I’m not asking you to help me out with this. It is my last question however.

    Best regards ??

    ggg377

    Thread Starter ggg377

    (@ggg377)

    keesiemeijer, thank you once again. That almost did it, “Today” and “Yesterday” are perfect, but now, posts under “get_the_date” get labels for each post. #post.first class seems to work correctly everywhere. I hope the label issue can be easily solved.

    For quick reference:

    index.html: https://pastebin.com/nYamPBQV
    Example of everything almost working: https://goldenred.web44.net

    Thread Starter ggg377

    (@ggg377)

    keesiemeijer, this is, simply put – awesome. The code indeed does the job exactly as intended. I double-checked and nothing seems to be hidden anymore. The main functionality works.

    However, one more issue (that I mentioned earlier) still remains, it broke a bit of code from my old loop. First, “Today” and “Yesterday” get duplicate date labels for each post. “the_date” works as intended for some reason, posts under that get grouped correctly. Code:

    <?php $w_h = $w_d = $last = 0; ?>
    
                    <div class="indexdate"><?php
        if ( date('Yz') == get_the_time('Yz') ) {
            if (!$w_d++) echo '<h6>Today</h6>';
        } elseif ( date('Yz')-1 == get_the_time('Yz') ) {
            if (!$w_h++) echo '<h6>Yesterday</h6>';
        } else {
            echo the_date('', '<h3>', '</h3>');
        };
    ?>

    Second, the class “#post.first” gets applied to all posts instead of being applied to the first posts of respective categories only. Code:

    <div id="post" <?php if( get_the_time('Yz') != $last ) { $last = get_the_time('Yz'); echo ' class="first" '; } ?>>

    I also drew some illustrations so it would be easier to understand:
    Labels: https://i.imgur.com/C0SO5gz.jpg
    Borders: https://i.imgur.com/S4KfxZo.jpg

    I hope you have some comments or ideas on these issues. Both of these work normally without the enhanced loop. I’ve had both of these problems since your first scripts. Really hope it’s possible to get these fixed.

    We’ve ventured quite far into unmarked WordPress territory. I hope other WordPress users will find this useful in the future.

    Thread Starter ggg377

    (@ggg377)

    Edit: found another issue. Only a maximum of 5 posts get shown per date (the “test” posts if there are any and the newest posts of other categories), an example is February 3, I have another post on that date, which isn’t shown. Other posts are hidden.

    Unfortunately I think I won’t be able to figure that out. Hopefully it’s possible to get that resolved, because overall, the code is exactly what I need.

Viewing 15 replies - 16 through 30 (of 65 total)