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

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

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

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

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

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

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

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

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

First triple check your file and path names for spelling mistakes. Then check the permissions of the .js file Then take the URL from your source and open it in your browser first without the ?ver=3.8.1. Do you get a 404 in your browser as well? Then you say you call your script after the head. How exactly? Manually written into a template file? Also I ...


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 can load your own .php files outside WordPress but you do not have WordPress' rewrite magic to support you. If you want to load the file from http://bhaa.ie/realex-ipn.php that file will have to be at the root of your installation-- same directory as license.txt. If your file is in your theme you have to load it with a complete path such as ...



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