Forum Replies Created

Viewing 12 replies - 16 through 27 (of 27 total)
  • Thread Starter Dot22

    (@dot22)

    I’ve tried to get it work but it didn’t. The code of the loop in my index.php page is:

    <?php /* The loop */ ?>
    			<?php while ( have_posts() ) : the_post(); ?>
    				<?php get_template_part( 'content', get_post_format() ); ?>
    			<?php endwhile; ?>
    
    		<?php else : ?>
    Thread Starter Dot22

    (@dot22)

    Thanks for your reply megafreechips. The code must be included inside the loop, right?

    Thread Starter Dot22

    (@dot22)

    Hello Jose,

    Thanks for your reply. This is the code of my index.php page:

    <?php get_header(); ?>
    <div class="content-path">Some text here</div>
    		<div class="container"><br />
    			<h2>News</h2>
                <?php $c = 0; if ( have_posts() ) : ?>
                <?php query_posts($query_string . '&cat=1'); ?>
    			<?php /* Start the Loop */ ?>
    			<?php while ( have_posts() ) : the_post(); $c++; ?>
    				<?php get_template_part( 'content', get_post_format() ); ?>
                    <?php if( $c == 2 ) :?>
    <div style="margin: -50px auto 10px;"><hr /></div>
    <?php $c = 0;
    endif;?>
    			<?php endwhile; ?>
    			<?php custom_content_nav( 'nav-below' ); ?>
    		<?php else : ?>
    			<?php if ( current_user_can( 'edit_posts' ) ) :
    				// Show a different message to a logged-in user who can add posts.
    			?>
    		<div style="text-align: center; font-weight: bold;"><?php _e( 'Nothing found.', 'custom' ); ?></div>
    			<?php else :
    				// Show the default message to everyone else.
    			?>
    		<div style="text-align: center; font-weight: bold;"><?php _e( 'Nothing found.', 'custom' ); ?></div>
    				<div style="text-align: center; font-weight: bold;"><?php _e( 'Nothing found.', 'custom' ); ?><br />
    					<?php get_search_form(); ?>
    				</div><!-- .entry-content -->
    			<?php endif; // end current_user_can() check ?>
    		<?php endif; // end have_posts() check ?>
    <div class="content-path2">More text here</div>
    <div align="right"><a href="#top">up? <span class="fa fa-arrow-circle-o-up fa-lg"></span></a></div></div>
    <?php get_footer(); ?>

    How can I use the is_paged() conditional? Thanks again!

    Thread Starter Dot22

    (@dot22)

    Thanks for the help Hector! I’m checking with the hosting if there is any restriction or problem regarding .htaccess exception.

    If I can solve the problem I’ll update this post with the solution (or at least the cause of the problem). Thanks again, and your plugin is awesome! =)

    Thread Starter Dot22

    (@dot22)

    I don’t use any plugin to strength the security of wp-admin folder. Just the .htaccess file. I’ve done a fresh install of WordPress with WordPress Popular Posts only.

    The password protection code is only on the wp-admin folder. I have two .htaccess…

    Inside /wp-admin folder:

    # Allow plugin access to admin-ajax.php around password protection
    <Files admin-ajax.php>
    Order allow,deny
    Allow from all
    Satisfy any
    </Files>
    
    AuthType Basic
    AuthName "Admin only"
    AuthUserFile "/var/www/inesc/data/etc/43109648.passwd"
    require valid-user

    On main WordPress directory:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    The result: all the pages on the front-side of the site (except index.php) are asking for a user/pass. Thanks again for all the help and replies!

    Thread Starter Dot22

    (@dot22)

    Sadly, the problem persists. I pasted that code on the .htaccess file inside /wp-admin folder and also changed the AuthUserFile path but didn’t work.

    The plugin is awesome.. there’s any alternative to continue using it and make WP admin panel more secure?

    Thread Starter Dot22

    (@dot22)

    Thanks again for the answer but it didn’t work… The front-end site continue asking for a user/pass on all the pages except index.php =(

    Thread Starter Dot22

    (@dot22)

    Actually this is the code of my .htaccess file…

    AuthType Basic
    AuthName "/www/path/wp-admin/"
    AuthUserFile /var/path/43109648.passwd
    <Limit GET POST>
    	require valid-user
    </Limit>
    
    <Files admin-ajax.php>
      Order allow,deny
      Allow from all
      Satisfy any
    </Files>

    But it didn’t work. The front-end side of the site continue asking for username and password. Maybe the .htaccess ignores the exception?

    Thread Starter Dot22

    (@dot22)

    I found the solution. After looking the code again and again, added…

    $cat_id = $category2->term_id;

    behind foreach echo. So the code I’ve now is:

    <?php $args = array ( 'orderby' => 'id', 'order' => 'DESC', 'number' => 1, 'parent' => 0 );
    $categories = get_categories( $args );
    foreach ( $categories as $category ) {
    	$args2 = array ( 'child_of' => $category->term_id );
    	$categories2 = get_categories( $args2 );
    	foreach ( $categories2 as $category2 ) {
    		echo "top 3 posts in: $category2->slug";
    		$cat_id = $category2->term_id;
    		$latest_cat_post = new WP_Query ( array ( 'posts_per_page' => 3, 'category__in' => array( $cat_id) ) );
    		if( $latest_cat_post->have_posts() ) : while( $latest_cat_post->have_posts() ) : $latest_cat_post->the_post(); ?>
    			<h1><?php the_title(); ?></h1>
    		<?php endwhile; endif;
    	}
    } ?>

    Thanks very much for all the help shadez! =D

    Thread Starter Dot22

    (@dot22)

    I’ve checked the posts again and they aren’t assigned to both subcategories. Maybe with a real example I can explain this better. I have two Categories (1 and 2) and the code get the posts inside category 2 succesfully. But inside category 2 I have subcategories… for example: Letters & Numbers.

    I want to display all the posts from Letters, and so on. Inside each subcategory I’ve two posts in this order…

    Post 4 – Letters
    Post 3 – Numbers
    Post 2 – Numbers
    Post 1 – Letters

    The last piece of code gives me this result:

    Subcategory: Letters
    Post 4 | Post 3 | Post 2

    Subcategory: Numbers
    Post 4 | Post 3 | Post 2

    and really I want to show:

    Subcategory: Letters
    Post 4 | Post 1

    Subcategory: Numbers
    Post 3 | Post 2

    Thanks again and excuse me if I’m not very clear.. =(

    Thread Starter Dot22

    (@dot22)

    Thanks again for the reply! =) I’ve tried with the new code, but now it lists the same last three posts from each subcategory or slug. I mean…

    Category 3
    – Subcategory A
    Post 4 | Post 3 | Post 2
    – Subcategory B
    Post 4 | Post 3 | Post 2

    I’m trying to make it works, but hasn’t had any results yet.

    Thread Starter Dot22

    (@dot22)

    Thank you a lot shadez! Works really great! =)

    One more question: Is there a way to display all the posts on the same subcategory next to each other? Like this:

    Category 1
    -Subcategory 1
    Post | Post | Post
    -Subcategory 2
    Post | Post | Post

    Thanks again!

Viewing 12 replies - 16 through 27 (of 27 total)