Hot answers tagged

3

I do not think that there is any sane way to sort this issue with the amount of posts you have except than setting hierarchical to false. Setting hierarchical to true has huge impact on performance and aren't really meant for use in custom post types. If you do not need a parent/child relationship between posts like the build-in post type page have, then ...


2

A 404 should never be a redirect. A redirection status begins with 3, not with 4. You can either include the index.php (or home.php or front-page.php) in your 404.php or just remove the 404.php from your theme. Then WordPress will use the index.php.


2

Of course it doesn't. When you remove get_header() you also remove the code that loads the CSS files, not to mention that you remove large blocks of necessary HTML markup. The template you've posted above is very, very broken. You've also left out get_footer() which will most likely leave your markup broken as well. Instead of leaving out get_header() use ...


2

EDIT From your comments, front-page.php is only used when a page is set as a static front page. Normal home pages, ie, when Front page displays is set to Your latest posts, index.php is used. All archive pages and the front page uses paged and not page, so you would need to set get_query_var( 'page' ) to get_query_var( 'paged' ). Any ways, you should not ...


2

I did what Rarst told me to do. First I searched around in the Pods Framework documentation. This solved my problem. Here's what the code looks like right now. <?php $params = array( 'orderby' => 'publish_date.meta_value DESC', 'limit' => 10 ); $fltNewsPods = pods( 'fltnews', $params ); while ($fltNewsPods->fetch()) { echo ...


1

The $post global is not set on 404 pages, which leads to the error you are getting. You can either check if $post is set or bail if the current page is a 404 page or do all of the above EXAMPLE /** * enqueue scripts used in frontend * */ function sama_enqueue_scripts() { global $post, $sama_author_review; if ( !isset( $post ) ) ...


1

As far as I can see, it is not possible to use a custom 404 ErrorDocument directive in your htaccess file because WordPress' index.php will always be found when processing the htaccess content. (unless ofcourse index.php got deleted for some reason) Because index.php is found, it will not trigger the '404 not found' ErrorDocument directive. The ...


1

function checkArtist() { $page = get_page_by_path($_SERVER['REQUEST_URI'].'/',OBJECT,'artist'); if($page){ header("HTTP/1.1 301 Moved Permanently"); header("Location: /artist".$_SERVER['REQUEST_URI']); } } add_action( 'wp', 'checkArtist' ); I add a custom hook using wp which as the article says: This hook is one effective ...


1

I had faced the same problem. I did the following to resolve it on an Ubuntu Server: In /etc/apache2/apache2.conf, edit AllowOverride None for /var/www/ to AllowOverride All Type in the following command to enable mod_rewrite for .htaccess sudo a2enmod rewrite Restart your apache server: sudo service apache2 restart The problem solved!!!


1

If you have access to the database, I suggest you create a mysql dump and then replace the old URL with the new one. After that, import the database again.


1

If you have a non-static request like: example.tld/some-slug/ then you will need to run WordPress to see if that slug is available. The webserver (nginx/apache) doesn't know that, because WordPress will have to inform us about that through the 404 response header. If your site has only few pages, then you could tell the webserver about it beforehand. ...


1

If I try to add &posts_per_page=15 to url, it doesn't work: it won't change number of post. I wonder if you're looking for a custom query variable, e.g. ppp, to change the number of posts for the main query: add_filter( 'query_vars', function( $vars ) { $vars[] = "ppp"; return $vars; } ); add_action( 'pre_get_posts', function( \WP_Query $q ) { ...


1

You custom post type is NOT public. Add following lines to your register_post_type array 'public' => true, 'publicly_queryable' => true,


1

Your custom post type is not publicly visible so you need to update your argument You can refer given link for that https://codex.wordpress.org/Function_Reference/register_post_type And if your custom post type publicly visible and still problem exist please Flush your permalink and try it. It will solve your problem.


1

After checking phpinfo(), mod_rewrite wasn't enabled so I enabled it: http://linuxcommando.blogspot.fr/2014/03/how-to-enable-modrewrite-for-apache-web.html and it worked !


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 ...


1

When clicking on any of those links, redirecting to an URL like "root/category/post-name/", the 404 template is loaded, If you remove the category_template filter, are the links still 404? For categories, your cpt post should appear in the list of posts in that category. So the url is root/category/. When clicking on any of those cpt links, the ...


1

The problem your GET param is using the same name as the query var for your custom post type. $link = $link_aqui_se_sirve.'?'.$establecimientos_cpt_name.'='.$tax->slug; With that URL, WordPress is expecting the value of the $establecimientos_cpt_name parameter to be a post slug. Instead you are giving it a taxonomy slug. This will give you a 404 unless ...


1

Actually I got to the bottom of it. The problem was that I have installed the WPML plugin. But I forgot to install the WPML Media plugin. As soon as I installed it, the attachment pages started working again. In my opinion, this is unacceptable and I will escalate the issue to WPML team. If the Media plugin is so critical, it should be made obvious to the ...


1

Problem solved. I was advised to download a fresh copy of wordpress, delete all wp files/folders on my site EXCEPT wp-config.php file and the /wp-content/ folder, and then replace the deleted folders/files with fresh copies. This worked!


1

For all those who might hit the same problem, here is the solution: Disable in Yoast the "remove category" option in advanced section. Then install this plugin: https://wordpress.org/plugins/remove-category-url/ ( do use any other plugin as this one works - yes, I tried them all) For some reason the Yoast solution and all other plugins don't allow ...


1

The easiest way is to check for get_current_blog_id(); and adjust your 404 template based on the current blog id. An other option is creating a child theme for every site and adding different page-404 templates.



Only top voted, non community-wiki answers of a minimum length are eligible