WordPress Plugin development and 404 error - wordpress

I have created some custom pages for my plugin, also I have a form which is submitted from the front-end. But, when submit button of that form is pressed, it redirects me to 404 page. After updating permalinks to "post-name", it works but all I want is that the form submit should properly work no matter what sort of permalink is set at the settings.
Some help on this will be highly appreciated.
Thanks!

use the normal link while submitting yourwebsite.com/?p=2 format this will work irrespective of permalink structure

One can use like this: action="<?php echo get_permalink( get_page_by_path( 'page-id' ) ) ?>" in the front-end form. Caution: page must exist.
Thanks!

Related

WordPress contact form 7 redirection

I want redirect contact us form 7 , for different pages,
I have multiple custom posts, and I want that when the user wants to read this, then first fill a form, and then redirect to full page. I want this process for every single post.
My test case can be seen here.
I am doing this:
on_sent_ok: "location.replace('http://polestarllp.com/casestudy/benefits-of-sql-on-hadoop/');"
But this is for only one page.
If it doesn’t work, check if Ajax is correctly working on your site.
follow this link
http://contactform7.com/redirecting-to-another-url-after-submissions/
For redirecting your contact form after submission . This is perfect method ,
on_sent_ok: "location.replace('http://polestarllp.com/casestudy/benefits-of-sql-on-hadoop/');"
But if you getting any issue then you can use redirection addon for contact us plugin .may be these link help you.
1:https://wordpress.org/plugins/tags/redirect-cf7/
2:https://github.com/anup04sust/Contact-Form-7-Redirect/blob/master/contact-form-7-redirect.php
3:https://github.com/kasparsd/contact-form-7-extras/blob/master/plugin.php
you need to call post id instead of this link ('http://polestarllp.com/casestudy/benefits-of-sql-on-hadoop/')
on_sent_ok: "location.replace('<a href="'. get_permalink($post->ID) . '"');"
hope it will work for you

Not showing a page template if one already is published

My scenario is simple.
I have a page template and if one page is saved under that custom page template type, it should not be available in the admin page template drop-down-box. Anybody know of a way to do this fast and easy? I can't seem to find an easy way to do this.
Ok as suggested by the user here goes:
why not loop through the
get_post_meta( $post->ID, '_wp_page_template', true ) );
to check if the page template is in the page's meta values and if it is remove it from the drop down..
something like this:
How to hide a template in Wordpress?
Should hide the template and something like this:
http://wordpress.org/support/topic/checking-for-the-existence-of-an-active-page-template
Will allow you to check the page template to see if it's being used...

Wordpress Search URL messing up for posts

I set up my search in header.php, and on the main site search works properly. When I search from within a story, however, I never can get to the search results page because it tacks on the /?s=searchterm in the URL after the post slug. How can I circumvent this issue?
What have you provided in the action of your search form?
Use action="<?php echo home_url( '/' ); ?>"
I think this will solve your problem. If not provide your site url so that it would be easier to trace actual problem.

wordpress get current permalink or url without domain

I'm not sure if I titled this correctly but this is my issue, I have to create 2 same exact blogs and the only difference is language. So but what I need is at the top when clicked on a language it would take the user to that same page but in the language he/she clicked on.
I'm using permalinks currently and I've tried the following:
<?php
function my_permalink() {
echo substr(get_permalink(), strlen(get_option('home')));
}
my_permalink();
?>
but that for some reason on my home page points to a post and not the home page. I believe that works in posts but I need that to also work on the home. Here's the links to both blogs, any help is much appreciated..
English: http://www.inblu.pe/prblog/
Spanish: http://www.inblu.pe/prbloges/
It could be more simple with standard PHP method :
$_SERVER["REQUEST_URI"]
Of course it will work for current post only.
You can also use that :
<?php
function my_permalink() {
echo substr(get_permalink(), strlen(home_url('/')));
}
my_permalink();
?>
How about the_permalink? I'm fighting with that now.
~ Justin

Wordpress' Contact Form 7 returns 404 but works on homepage

I've installed Contact Form 7 (v 3.1.1) into Wordpress (v 3.3.1). It works fine on the homepage (which is a static Page called 'Home') but on any other page it does nothing and the console says:
POST http://trademarkshop.ca/contact/ 404 (Not Found)
I'm using do_shortcode to call it from both theme files:
<?php echo do_shortcode('[contact-form-7 id="212" title="Contact form"]'); ?>
I have wp_footer() in the footer and wp_head() in the header. I have no other plugins installed. I've even checked for if(is_home()) restrictions. I also tried re-directing other pages to use the Home page template file, but still gives a 404 error.
I've never had this problem before. Any ideas would be very appreciated!
have you tried changing your permalinks to something else,
then save,
then change it back to /%postname%/
could be its not creating the htaccess file in the wp root,
hence your permalinks arent working,
Marty
use this code
<?php echo do_shortcode( '[contact-form-7 id="7" title="Contact"]' ); ?>
His problem is caused by a combination of two misconfigurations. First, AJAX JavaScript is not functioning on your contact form. Due to this problem, your contact form needlessly redirects after submission. Second, your contact form uses unavailable words in the names of input fields. This issue confuses WordPress, resulting in the 404 (“Not Found”) error.
https://contactform7.com/faq/my-contact-form-always-redirects-to-404-error-page-after-submission/
Change your Contact form 7 field names. Because some names already using by wordpress may be is conflicting.
Example:
name to username
Sometime that happen cause the code (id) in de form (When you try editing the error message on the left side there is a short html like code on witch there is an id) is not the same as the one when you go to dashboard>contact and the short code entry of the table. You need to change the first one to match the second one

Resources