svedish
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Adding a static element also before PAGES in permalinksAny chance someone knows about this issue? I was hoping for Otto to jump in?
Sorry and thanks again.
Forum: Fixing WordPress
In reply to: WP_Query no space in arguments?Hi all,
Ok, I have joined the IRC channel of WordPress and I got an answer that sounds conclusive, so I’ll update this post in case someone else needs to find out the answer to these questions.
As far as they told me it is NOT allowed to use spaces in that form of query passing. That is why WP_Query doesn’t behave as expected when spaces are used.
Another good way to write the query is by using an array notation like this:
WP_Query(array('post_type' => 'london_hotel'));
Hope this will help someone else as well.
Take care
Forum: Fixing WordPress
In reply to: WP_Query no space in arguments?I wonder if I should open a bug report for this? Is anyone else able to reproduce this behavior?
Thanks. ??
Forum: Fixing WordPress
In reply to: WP_Query no space in arguments?Hi Esmi,
I have reinstalled WP 3.1.3 from scratch. Plain vanilla…
??I have created two more posts (Post two and Post three)
??I have then created three pages: Page one, Page two and Page three.
? I have created a page called Page list that use a template called ‘Page listing’.
??Inside this template I have put this code:<ul> <?php $my_query = new WP_Query('post_type=page'); while ($my_query->have_posts()) : $my_query->the_post(); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> <?php wp_reset_postdata(); ?> </ul>
The Page list page displays, correctly, a list of all available pages
* Page list
* Page three
* Page two
* Page one
* Sample PageIF I add a SPACE before and after the equal sign of the WP_Query argument
new WP_Query('post_type = page');
the list displays:
* Post three
* Post two
* Hello world!Meaning that the loop is falling back to listing the posts available, not the pages (i.e. posts of post_type page).
Sorry, I don’t know what you have done, but I can confirm this doesn’t seem to work as I’d expect.
Forum: Fixing WordPress
In reply to: WP_Query no space in arguments?That’s incredible…Can you please send me the WP_Query code you have used? I’ll install a plain version of WordPress and I’ll try it with no code hacks and plugins installed.
Thanks.
Forum: Fixing WordPress
In reply to: WP_Query no space in arguments?I also use spaces all the time in PHP for better readability.
Have you tried to reproduce my example using spaces in the WP_Query – i.e. WP_Query(‘page_id = 3’) instead of WP_Query(‘page_id=3’)?
Thanks for helping!
Forum: Fixing WordPress
In reply to: WP_Query no space in arguments?TextWrangler is the Free version of BBedit, so all that can be done with TextWrangler can be done in BBedit.
Also, and of course this is NO conclusive proof, in the WP_Query manual page, in all examples that make use of an equal sign there is no use of spaces, never. https://codex.www.ads-software.com/Class_Reference/WP_Query
This makes me thing that maybe that piece of code gets appended to some query and possibly doesn’t like spaces? Just a random thought from a non expert…I really can’t figure out why this happens, but I doubt it’s a question of encoding to be honest.
Forum: Fixing WordPress
In reply to: WP_Query no space in arguments?Sorry Esmi,
ANSII is not even available in BBedit as a “Save as” option. To be honest I highly doubt the problem is the encoding… But I am happy to give it a shot, if I only knew how to save the file as ANSII. I’m on a Mac.
Forum: Fixing WordPress
In reply to: WP_Query no space in arguments?That would be Unicode (UTF-8).
Forum: Fixing WordPress
In reply to: WP_Query no space in arguments?I’ve created another page and template which is identical to the other but have two spaces around that equal sign. They both list (should list) the posts of post type london_hotel. Only the one with no spaces works.
Forum: Fixing WordPress
In reply to: WP_Query no space in arguments?I can use whatever. I was using the FTP app text editor (Transmit), but I just copied the whole code into BBedit and created a brand new file and all the problem persists. By the way, I have used the FTP editor for years to edit any sort of php file, inside and outside WordPress, so I doubt that could be the problem. Am I spotting a bug here? Is it worth escalating the thing?
Forum: Fixing WordPress
In reply to: WP_Query no space in arguments?Hi Esmi,
In fact, PHP is not space sensitive. That’s why I was so surprised!
You mean the code of the same file? It’s really not that long because it’s just a test.
It’s just a separate template (* Template Name: Hotels listing) that displays a list of posts of that custom type. Nothing else.
Just get header, do this loop, close the query and get the footer.
Weird… :S
Forum: Fixing WordPress
In reply to: WP_Query no space in arguments?Hi Esmi,
Thanks for your answer, but I am trying again right now. If I add spaces between the equal sign and both terms to the left and right the code doesn’t display the list of post items anymore (it just displays one list item and the one URL with no anchor text that points to the first post in the blog https://MYDOMAIN/cms_tests/wordpress/?p=1). The code is the following:
<ul> <?php $my_query = new WP_Query('post_type = london_hotel'); while ($my_query->have_posts()) : $my_query->the_post(); ?> <li><a href="<?php the_permalink(); ?>"><?php the_field('hotel_name'); ?></a></li> <?php endwhile; ?> <?php wp_reset_postdata(); ?> </ul>
When I remove the spaces (OR if I remove JUST the space after post_type)
<?php $my_query = new WP_Query('post_type=london_hotel');
or
<?php $my_query = new WP_Query('post_type= london_hotel');
it works and both the titles of the posts are listed as links (I have two posts of type london_hotel). By the way if you see the_field(‘hotel_name’ it is because I’m using Advanced Custom Fields).
Weird…What do you think?
Forum: Installing WordPress
In reply to: Upgrading from 2.8.4 to 3.1.3Hi again,
By the way, the ‘Read me’ page tat comes with version 3.1.3 says that to upgrade from any version newer than 2.7 it is possible to use the Automatic upgrade option. Theoretically, having installed 2.8.4, I could just make the leap? Of course I’d backup files and DB multiple times. ??
Thanks a lot.
Forum: Installing WordPress
In reply to: Upgrading from 2.8.4 to 3.1.3Hi Govpatel,
thanks for your answer. I just created my theme to reflect the general layout of the main websites. I just used the same HTML layout, broke it down into pieces and used the WP tags here and there (like <?php if (have_posts()) : while (have_posts()) : the_post(); ?>) to output the blog stuff. Simple as that. ?? What should I check to be sure that the theme won’t break? Perhaps that the tags are still in use?
Thanks!