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


4

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


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

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

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

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

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

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

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

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

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

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



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