Tag Info

Hot answers tagged

4

You don't need to add anything special to the top of 404.php. WordPress will know to use 404.php automatically when it tries to get a post or page and fails. To create a custom 404 page for a theme, the simplest way is to: Copy the index.php file from the current theme to a file called 404.php. Edit your new 404.php to delete the code dealing with ...


3

Creating a secondary query or overwriting the main query inside a page template is the quickest and easiest way I know to break pagination. The main query, which determines which page to load runs before your template thus the results on the page and the query that loads the page become out of sync. The main query does not know about your in-template ...


3

Headers are sent long before you try to alter them. Headers are sent by actions associated with get_header(), so by the time your code executes, it is too late to alter the headers. You can demonstrate this with a simple experiment. Try each of the following: get_header(); status_header( 404 ); and status_header( 404 ); get_header(); In a template ...


3

Without testing, I'll guess this has nothing to do with the author names specifically, but the fact that author is a built in WordPress query var, and /author/author-name/ is the default permalink for author archives. Change your post type name so the query var no longer clashes, then either change your post type rewrite slug, or change the the default slug ...


3

You should definitely avoid the public WordPress query vars: attachment attachment_id author author_name cat category_name comments_popup day error feed hour hour m minute monthnum name p page_id paged pagename post_parent post_type preview second static subpost subpost_id tag tag_id tb w year There's also this list of reserved terms, inexplicably located ...


3

Edit file wp-config.php in root & define site url and home url: define('WP_HOME','http://example.com'); define('WP_SITEURL','http://example.com'); And go to admin dashboard and update permalink (Settings => Permalinks => Update).


2

It sounds as though WorldPay is responsible for sending the overly generic name parameter so you aren't in a position to control that. You will instead have to catch the request and force it to work. Something like: function redir_404_wpse_137703() { if (is_404() && isset($_GET['name'])) { locate_template('some-theme-template.php',true); ...


2

Things are working the way they are supposed to, and possibly the only way they can work. Let me explain. Without an Apache module called mod_rewrite (or the equivalent Nginx or IIS component) requests to PHP pages have to go to an actual filesystem file. That is what you see with requests like 192.168.1.8/wordpress/?p=123. The file being accessed is the ...


2

Depends on what you mean by "redirect". If you want to 404 them, this will do the job: add_filter('wp_die_handler','custom_404_die_handler'); function custom_404_die_handler() { global $wp; $wp->handle_404(); load_template(get_404_template()); die(); } If you actually want to redirect them somewhere, then you could do something like ...


2

Put your code in the template file category.php. Remove all the part before the loop: once in category template, you don't need to get the category, get the paged, run again the query with query_posts... So your category.php should simply appear like so: if ( have_posts() ) : while ( have_posts() ) : the_post(); $image = wp_get_attachment_image_src( ...


2

Remove the slashes on your rewrite slug. Should be like so: ... 'rewrite' => array('slug' => 'products', 'with_front' => false) ... Also, you can't have the same slug for both a taxonomy and a custom post type. They need to be unique, otherwise WP won't know which one applies to which. Additionally, if you have the slug of your ...


2

All your inner links use the wwww subdomain instead of the www subdomain. Check your General Settings to see if you added an extra w in your site url. For example: This fails: http://wwww.erogol.com/?p=653 This succeeds: http://www.erogol.com/?p=653


2

In wamp you have to manually click/unclick an option to change the .htaccess(and allow permalinks with that). To do this , click the wamp icon on your (windows) task bar, choose apache > apache modules and check 'rewrite module'


2

get_the_ID() is broken. function get_the_ID() { return get_post()->ID; } It tries to use the member ID on a function that returns a post object sometimes: /* * @return WP_Post|null WP_Post on success or null on failure */ function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) { get_posts() can return NULL, and NULL has no ...


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.


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

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


1

you're using name='name' for your first input. That breaks it. Change the name to something else as suggested above, prefix everything. name='my-prefix-name'


1

This is an issue when installing mod_security2. The solution is as simple as disabling mod_security or allowing that page to POST that request. The issue is that mod_security thinks someone is trying to hack into your site.


1

Why do you want to customize the 404's core. One theme always has a file 404.php. You can do normally everything and display in this page (Get some post, images,link, tag....). If you want add a hook, try this: Are there any hooks that alter the 404 logic? Good luck.


1

There are several possibilities: you may need to enable mod_rewrite on the Ubuntu server or check/fix permissions to allow Wordpress to write to the .htaccess file. Best thing to do is read http://codex.wordpress.org/Using_Permalinks and work through suggestions.


1

Based on your comments above: Oo, thanks, good questions. Just realized now that the Settings > Reading has nothing selected for Posts page. (The Front Page is of course set for the static home page.) The problem is, indeed, that you have failed to assign a static page as the posts page (the page ID that WordPress uses to display the blog posts ...


1

A couple of points you should try out: Remove the 'paged' => $loop->query_vars['paged'] from your $pagination array. It's not a parameter in the docs. Remove the 'base' => @add_query_arg('paged','%#%') from your $pagination array. I believe WordPress catches the paged parameter using the default page parameter. Which is it's default. Here are ...


1

I am about 99% sure the reason for much of this is that someone has used relative links in the post body. A link that looks like this: <a href="www.whufc.com/">Some link Test</a> Will end up looking like this: 2010/premiership-forecast-title-race-hots-up-gunners-prepare-for-adebayor/www.whufc.com/ If it shows up on this page of the site: ...



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