rafaelxy
Forum Replies Created
-
Forum: Themes and Templates
In reply to: Pagination with custom post type listingput this code in your functions.php
https://rafaelxy.pastebin.com/VtHQEkH7and use this custom_query_posts() function instead of “new WP_Query()” or “query_posts()”
just remember to pass the params as an array, and not as a query string.
Forum: Themes and Templates
In reply to: Pagination with custom post type listingI’m back on this thread after months, I’m glad a lot of people managed to find it and get helped ??
@vayu the global variable,
global $wp_query
changes according to the URL that your HTTP request is requiring. If you are going to custom modify its behaviour inside a page (eg: listing a custom post type), you NEED to reset it using
wp_reset_query();
so no parameters from the HTTP request get in the way of your custom query.
Forum: Fixing WordPress
In reply to: Error 404 on pagination when changing posts_per_page on query_postsI tryed out your plugin, but had the issue was still happening, I solved like this:
Forum: Fixing WordPress
In reply to: Custom Post Types Pagination not working (404 error)Dude, I answered this same doubt on another thread:
Forum: Themes and Templates
In reply to: Pagination with custom post type listing@takeok:
glad I’m helping!I did a function as well that you can use it instead of the wordpress query_posts(), this function does exactly the same but adding some more stuff that is need to pagination work correctly on custom post types pages:
Forum: Themes and Templates
In reply to: Pagination with custom post type listingAfter a looong day debugging thru wordpress core, I managed to solve this issue.
Basicly, you CANT have a PAGE and a CUSTOM POST TYPE with the same name. If you do, the permalink rewrite rules will get confused and trigger a 404.
A very simple solution I’m using 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 dont conflict and it’s all fine.
Done Done!
Hope this will save people’s time.Forum: Alpha/Beta/RC
In reply to: WP 3.0 Permalinks are Brokenbump,
same issue here
You can like you are doing, but I rather rely on a apache setted variable. You can do this on your .htaccess.
.htaccess
SetEnv ENVIRONMENT production
wp-config.php
define('ENVIRONMENT', getenv('ENVIRONMENT')); if (ENVIRONMENT == 'production'){ define('DB_NAME', 'productionSettings'); define('DB_USER', 'productionSettings'); define('DB_PASSWORD', 'productionSettings'); define('DB_HOST', 'productionSettings'); define('DB_CHARSET', 'productionSettings'); define('DB_COLLATE', 'productionSettings'); }else{ define('DB_NAME', 'otherSettings'); define('DB_USER', 'otherSettings'); define('DB_PASSWORD', 'otherSettings'); define('DB_HOST', 'otherSettings'); define('DB_CHARSET', 'otherSettings'); define('DB_COLLATE', 'otherSettings'); }
The $_SERVER[‘HTTP_HOST’] is more to rely on a url base, like wordpress options siturl and home, that you could use like that:
wp-config.php
define('WP_SITEURL','https://'.$_SERVER['HTTP_HOST']); define('WP_HOME','https://'.$_SERVER['HTTP_HOST']);
You still have to update post’s guid when changing the environment