Wordpress Search URL messing up for posts - wordpress

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.

Related

Where is Wordpress search parameter checked?

This is going to sound stupid but I am stymied. As I've learned a search form is recognised by Wordpress when the name of the input is gives as 's'. The action is always the home url. But nowhere in index.php or page.php(depending on your homepage setting) does it check for the parameter 's'. Where exactly does Wordpress check for this parameter?
I am trying to output the search result on a particular page but it does not work when I set the 'action' value to anything but the Home URL. I am hoping I can gain further understanding on how search works and maybe implement the same parameter checking in my desired page
Howdy_McGee check this out
WordPress doesn't require that search goes back to the homepage. The s query var is a reserved keyword for WordPress search. What you can do is modify your search form to include the current url:
global $wp;
<form role="search" method="get" class="search-form" action="<?php echo esc_url( home_url( $wp->request ) ); ?>">
By doing so on a term page ( taxonomy archive ) it will also restrict the search to that specific term without any additional work. You can modify this in your searchform.php template. If you don't have one you can grab it from the 2017 theme files.
WordPress parse most requests through the class-wp-query.php file handed by the WP_Query Class/Object. Search is handled by WP_Query::parse_search()
If you're looking to modify the search or really any queries you can always use pre_get_posts to change the query object before it's requested from the database. If you want to modify the SQL before it's requested you can use the posts_clauses hook, usually this is used for incorporating custom tables.

WordPress Plugin development and 404 error

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!

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

custom taxonomy terms page not found Wordpress

I’m getting a Page Not Found message when clicking on the link to display the terms in a taxonomy
Scenario:
I have a custom post type called "glossary"
Attached is a custom taxonomy called "section" with the rewrite set to “library/glossary-start-here”
I created a page that lists the terms in the taxonomy. This is a Wordpress page with the slug of “glossary-sections” - the template for the page is set to “taxonomy-section.php”. The page is a child of “library” and so the permalink for the page is “example.com/library/glossary-starts-here/glossary-sections/"
The template “taxonomy-section.php” has the following code:
<?php // Begin header section.
$argterms=array(
'include' =>array(
117,118,115)
);
$terms = get_terms('section', $argterms);
echo '<ul>';
foreach ($terms as $term) {
echo '<h3>' . $term->name . '</h3>';
}
echo '</ul>'; ?>
<div>
<?php
When clicking on the link to the page “glossary-sections”, which is used on a number of other pages, I get a page not found message.
I know the template does its job because on some occasions as I've poked around troubleshooting I've had it working. However, I can't find a consistent condition that causes the page to work. I suspect that the problem has something to do with the rewrite but my tests have been inconclusive.
I’d appreciate any suggestions on why this isn’t working and how to correct it.
I’m particularly puzzled by the fact that I can specify a page like “glossary-section” and yet have it not be found.
Thanks.
As I understand it, WordPress has a hierarchy / parse order (so to speak) as to what it looks for when it gets a request. Technically, a taxonomy is just a tag.
I'm not sure if this will help:
http://justintadlock.com/archives/2009/06/04/using-custom-taxonomies-to-create-a-movie-database
But J.Tadlock is always a solid place to start.
The source of the problem was that I had included a rewrite for the taxonomy, while at the same time using pages with assigned templates.
Once the rewrite was removed it appears that everything worked correctly.

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