Tag Info

New answers tagged

1

Are you sure that you don't have a page with the same name of the custom post type? If you do, the permalink rewrite rules will get confused and trigger a 404. A very simple solution is: The page that lists the custom post types is called in plural (eg. products) and the actual post type name is in singular (eg. product). So they don't conflict and it's ...


0

i found a solution with no use of htaccess but using the WP function wp_redirect. copy and past on functions.php function redirect_paginated_404() { if (is_404()) { $url = $_SERVER['REQUEST_URI']; //read the url $search = '/page/'; //chose the word of the url if ( strpos( $url, $search ) !== false ) { //if i find the string /page/ ...


0

OK, thank you to ialocin, the $gbquery->max_num_pages solve it! So there is the clean code : function livredor_function($atts,$content=''){ extract(shortcode_atts(array( id => '' ), $atts)); ob_start(); function create_guestbook() { $current_page = (get_query_var('paged')) ? get_query_var('paged') : 0; ...


0

I see three options here, but before I start, just a few notes on your code Do not use $wp_query as your query variable. This is the global query variable used by the main query which also holds the main query object. The way you have used it breaks the main query object and sets your custom query to it. You should avoid this method at all times as many ...


2

If I understand you correctly you just want to display a different amount of posts at archives, for this you don't need a custom secondary query at all. You can control it via pre_get_posts hook, either making use of posts_per_page or posts_per_archive_page parameter. Example for pre_get_posts function wpse188786_different_number_of_posts_for_archive_ppp( ...


0

Change your query code to this: add_filter( 'post_limits', 'my_post_limits' ); // The Query $wp_query = new WP_Query( $args ); remove_filter( 'post_limits', 'my_post_limits' ); In your theme/functions.php, add this: function my_post_limits( $limit, $query ) { return 'LIMIT 0, 30'; }


0

The answer is to specify all the args on the add_filter() call, and then you can have both the array of posts and the query sent to the callback. add_filter( 'posts_results', 'do_stuff', 10, 2 );


2

Drop your custom query and go back to the default loop. Never replace the main query on the home page or any kind of archive page with a custom query. Use pre_get_posts to alter the main query variables before the main query runs Your taxonomy archive page should look like this if ( have_posts() ) { while ( have_posts() ) { the_post(); ...


-1

Try this: $args = array( 'posts_per_page' => 5, 'paged' => get_query_var('paged') ); $query = new WP_Query( $args ); if ( $query->have_posts() ): while( $query->have_posts() ): $query->the_post(); // Template loop here endwhile; else: // No posts with query endif; if( function_exists( ...


0

WordPress generates an archive page when your register the CPT. As stated you can modify posts per page from your functions file and register both the CPT and Taxonomy support using this code: add_action( 'pre_get_posts', 'set_items' ); function set_items( $query ) { if( $query->is_main_query() && !is_admin() && is_post_type_archive( ...


0

If you used people and location as custom taxonomies, you'd be able to build them into a new WP Query instead. In fact, depending on how you're storing your custom fields, you might be able to do it through WP Query without going down the custom taxonomy route. Then, you don't need to post request anything - the query handles everything.


-1

Well if i need to use Pagination i will go with WP-PageNavi plugin. $paged = get_query_var('paged') ? get_query_var('paged') : 1; $args = array('post_type' => 'post', 'posts_per_page' => 5, 'paged' => $paged); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); // Your Custom Loop Code Here endwhile; ?> ...



Top 50 recent answers are included