Tag Info

Hot answers tagged

8

You may be surprised, but there is nothing strange there. First of all let's clarify that in WordPress when you visit a frontend url you trigger a query. Always. That query is just a standard WP_Query just like the ones to run via: $query = new WP_Query( $args ); There is only one difference: the $args variable are generated by WordPress using the ...


2

You should wrap your enqueue/register function in your conditional, not your add_action() You can try something like this using the is_404() conditional check function enqueue_404_script() { if(is_404()) { //do what you need to do } } add_action( 'wp_enqueue_scripts', 'enqueue_404_script' );


2

It turns out that the nginx config that W3 Total Cache inserts if Disk Enhanced mode is enabled will break permalinks, but only if you restart nginx after W3 Total Cache injects the config for Disk Enhnaced mode. Based on birgire's suggestion, I turned off all plugins and checked the site, which started working correctly. I then turned on W3 Total Cache ...


2

Your get_author_posts_url() seems wrong, it doesn't accept three parameters. Passing ID as first one should be sufficient to generate correct link, name argument is pretty redundant there.


2

Error pages are served up via .HTACCESS, if you are using Apache you would use the ErrorDocument directive and add the status and URL to it. So it would look like this in your .htaccess file: ErrorDocument 401 http://yourwebsite.com/error-401 ErrorDocument 403 http://yourwebsite.com/error-403 ErrorDocument 500 http://yourwebsite.com/error-500 You could ...


2

You will want to run a find-and-replace script across the database to update all URLs to reflect the new domain. Just because you change the WordPress settings doesn't mean the content stored in the database has been updated with the new domain! I've had good luck with the Velvet Blues Update URLs plugin but you can also do this type of find and replace ...


2

I cracked it! In my case I first created an author.php page (my theme lacked one) from the archive.php by cloning and cleaning it. Then I found this piece of code: <?php if ( have_posts() ) : ?> It basically says: if the authors has published some posts, then... Well, I just added: "OR NOT!" <?php if ( have_posts() || !have_posts() ) : ?> ...


1

When a URL is processed by Wordpress, its index.php script is loaded with the path to the requested page. Because in this case the index.php script is always found, a normal 404 error will never trigger (via ErrorDocument 404 …). If the requested URL does not match a page that WP knows about, WP will display its own "404" page. Unfortunately, if WP ...


1

There is currently a bug in the functionality that handles the NOBLOGREDIRECT constant, which causes 404 errors on the main site to be redirected to the value of the constant. Apparently this is the expected behaviour for sub-directory networks (example.com/subsite), but should not take place on subdomain networks (subsite.example.com). There is a WordPress ...


1

Flush the rewrite rule from dashboard -> Settings->Permalink page. Click on save button and then check your slide details page. It will work now. Otherwise you can write this code flush_rewrite_rules() in your create_slide_post_type() function. See the Codex


1

You should set your publicly_queryable argument to true when registering your custom post type. TAKE NOTE: Add flush_rewrite_rules(), refresh the page once or twice and REMOVE IT IMMEDIATELY. You SHOULD NOT keep flush_rewrite_rules() unless under the provisions as in the codex. this is an expensive operation so it should only be used when absolutely ...


1

You can include the search form in your 404.php file using the get_search_form() function. Using get_sidebar( '404' ); would look for a file called sidebar-404.php and fall back on sidebar.php if needed. get_sidebar()


1

It is possible but wordpress doesn't have any helpful constructs to help with that. The best approach is to modify your 404.php. Most of the information that you need should be in the main WP_query object and you should be able to do something like if (is_singular('post_tyoe_a')) { .... } else { .... } this is extremely untested and you might need ...


1

I have run into the same issue that using $wp_query->set_404(); would properly adjust the global object but not return the 404 template. So in the plugin I was writing I used the tried and tested method: add_filter( 'template_include', 'wp_139917_force_404' ); function wp_139917_force_404(){ global $wp_query; $wp_query->set_404(); ...


1

The no no about loading wp-* files directly are reasonable when you are developing a WordPress plugin or theme, but if you are developing an external code that require WP (and that seems your case) than you must require that files, there is no alternatives. Consider that including wp-blog-header.php is needed when you need to handle WordPress urls, or full ...


1

This should work: RedirectMatch 301 ^/products/cool-tshirt$ http://yourdomain.com/tshirts$1 You can also see a bunch of other options and solutions here Hope this helps.


1

I fixed the problem by editing my .htaccess file. I replaced it with the following. # BEGIN WordPress <IfModule mod_rewrite.c> ErrorDocument 404 /index.php?error=404 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress


1

You can create differents footers and headers files. For example, a default header.php and footer.php and specific templates like header-error.php and footer-error.php. In general, you will have this code to inclue header.php and footer.php: get_header(); //Your page tempalte get_footer(); In 404.php template file you can include header-error.php and ...


1

Best practice is to keep wp_footer() in your footer.php. Although the codex says, and I quote Put this template tag immediately before tag in a theme template (ex. footer.php, index.php). it is best keeping wp_footer() in the footer. From the PluginAPI for the wp_footer action When included, the default output for this function is the admin ...


1

There are a couple of things I don't understand here, but I'll try answering them as I go along. You have a home.php, which I assume is your default homepage. You have one line of code in there, and that is to call a another page template. Here is you code <?php require dirname( __FILE__ ) . '/blog-page.php'; In blog-page.php you have the complete ...


1

This is a Site I maintain hosted on GoDaddy. All HTML seen by the outside world is stored in the /public_html directory. Therefore /public_html is considered the root directory of my server. This site runs on WordPress 3.9.1. All that was done, was that GoDady's custom installer package unzipped the WordPress download zip to the /public_html directory. ...


1

In functions.php function productsPageRedirect_404() { global $post; if( is_page('products') ) { global $wp_query; $wp_query->set_404(); status_header(404); } } add_action( 'wp', 'productsPageRedirect_404' );


1

It is no only name or email problem, as Tom wrote. I had problem even with input field with name attribute same as one of my Custom Post Types. For example: ... <input type="text" name="movie"> ... And when having registered CPT "movie" somewhere else, your form submitting will end with 404 error. Conclusion: Don't use name, email and any ...


1

Just had exactly weird "from" word issue on a single post, and traced it to Wordpress SEO plugin by Yoast. It may be a sum of other causes for sure, as this got away so far up to this versions. Using the latest versions by now: Wordpress SEO plugin by Yoast, Version 1.6.3 Wordpress 4.0 Deactivating Wordpress SEO plugin, instantly allowed me to edit the ...


1

The first section of this question have been answered before. Basically, there are no index pages for archives, and there never will be. For a complete explanation, feel free to check this post I have recently done on this subject. Why did wordpress think that is post_name and post type is post? You might or might not know this, but Wordpress uses ...


1

That is totally normal behaviour. If you want to remove category base you will need to write some custom rewrite rules, not simple rules I must say. From my point of view, removing category base requires a extra job in each request that is worthless because it doesn't provide any advantage for SEO or for better site navigation. Some popular plugins, like ...


1

There is 404.php in the theme uploaded. But when there is search for non-existent page. The 404.php does not show up. When there is search for non-existent page doesn't produce the 404 page, but simply shows the search.php's else portion. A simple search.php is like: <?php if( have_posts() ) : ?> <?php while( have_posts() : the_post(); ...


1

You can replace the broken functions.php file, recovering it from the original theme package. From the namespace of your error message I can guess that the theme you are using could be this: https://wordpress.org/themes/catch-box Right? I hope it helps.



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