Thread Starter
Brisch
(@brisch)
Thanks I saw both of them. The first link revers to the cathegory.php and the plugins mentioned in the second are too old.
The first link doesn’t just refer to category.php though. Read through it again. A theme’s category.php is just built off index.php, which it sounds like maybe is the template you want to edit (if you only want to alphabetize the blog/front page).
Have you created a child theme? That might be the best way to start going about these sorts of changes on specific screens.
Thread Starter
Brisch
(@brisch)
Yes, I have a child theme. And sorry, I still can’t find what code to add to the functiond.php. Can you please copy the code in your answer, thank you.
-
This reply was modified 6 years, 4 months ago by
Brisch.
if you want to sort the post in the posts page and all archive pages, including search result, try this code:
function posts_sort_alphabetical( $query ) {
if ( is_admin() || ! $query->is_main_query() )
return;
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
return;
}
add_action( 'pre_get_posts', 'posts_sort_alphabetical', 1 );
Thread Starter
Brisch
(@brisch)
Thank you! It did not work.
https://betriebsrat-kwp.uni-ak.ac.at/wp-content/uploads/2020/01/alphabet.png
“K” is still before “F”
-
This reply was modified 6 years, 4 months ago by
Brisch.
Thread Starter
Brisch
(@brisch)
what theme are you using?
what is the full code of the theme’s index.php file?
Thread Starter
Brisch
(@brisch)
Fluida Plus (child) Cryout Ceations
http://demos.cryoutcreations.eu/wp/fluida/
This is the index.php – but it is not in the child theme now
<?php
/**
* The main template file.
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
*
* @package Fluida
*/
get_header();
?>
<div id="container" class="<?php echo fluida_get_layout_class(); ?>">
<main id="main" role="main" class="main">
<?php cryout_before_content_hook(); ?>
<?php if ( have_posts() ) : ?>
<div id="content-masonry" class="content-masonry" <?php cryout_schema_microdata( 'blog' ); ?>>
<?php /* Start the Loop */
while ( have_posts() ) : the_post();
get_template_part( 'content/content', get_post_format() );
endwhile;
?>
</div> <!-- content-masonry -->
<?php fluida_pagination(); ?>
<?php else :
get_template_part( 'content/content', 'notfound' );
endif; ?>
<?php cryout_after_content_hook(); ?>
</main><!-- #main -->
<?php fluida_get_sidebar(); ?>
</div><!-- #container -->
<?php
get_footer();