WP: Page Not Found - wordpress

I am using WP-3.3.2 and had created a website eyepractice my script gets month and year from url and then shows calendar for that month and year but when I integrate with Wp it only work for year 2012 and if I use http://www.eyepractice.ca/optometris/guelph/?month=1&year=2013 it shows Page Not Found however I have already created a Page named guelph from Wp admin. I searched whole project for 2012 but it is not hard coded.

This is a REALLY old question, but I came across it while looking for solution to the exact same problem, so I will leave an answer here.
I used a calendar creation script based on this link:
http://davidwalsh.name/php-event-calendar
In Wordpress apparently using 'year' and 'month' as $_GET variables conflicts with Wordpress internal query variable handling, so the calendar only worked for current year for me and threw a 'page not found' error on the next year.
The solution was simple. As #janw suggested, change the parameter names. In the script wherever $_GET variable is called 'month' or 'year', change it to something else like 'cal_month' or 'cal_year'. Works like a charm.

Related

ACF : date ISO to Timestamp don't give the right minutes

I'm currently doing a website with ACF plugin. I get some data from an API (I have a json result).
In this result, I get this 2019-05-02T09:00:00Z. I need to add this into my ACF field. This is almost working thanks to the strtotime() function.
But instead of having this result : 02/05/2019 09:00, I have this one : 02/05/2019 09:05
What adjustment should I make to fix that (it's a Wordpress site, so in PHP only please) ?
Edit : my ACF function :
update_field('field_5bcce1711c3d5', $arrayParam["end"], $eventIdDB);
I've seen on forum that ACF is working with unix timestamp

Wordpress add search filter

I want to filter posts by date where i can select multiple dates. ie 2013 & 2014.
I had been using a plugin called annual archive but this only allows you to select one, 2013 or 2014.
I've used a plugin to allow me to execute php from the text widget, so I've created a form with checkboxes and appropriate date ranges etc but wasn't sure where to send it to, so I sent a get request to a new file i made in my theme (so it wouldn't 404 and i could locate it).
I managed to process the query parameters and run a query_posts() call to get the posts. In this file, I copied a template file from my theme and now it generates with my posts.
My url is however, /wp-content/theme/.. etc which is not ideal.
The posts are all under categories, could I redirect to the /category/x page but get it to use the posts i've already found?
Is there a better way of doing things because this feels really hacked but I couldn't find a better way..
Edit: Seems like using
add_action('pre_get_posts', 'my_func');
function my_func($query){ $query->set('year', 2014); } in functions.php
is the way to go. Now I just need to figure out how to do year 2013 or 2014...
Edit 2: $query->set('date_query', [['year' => 2014], 'relation' => 'OR', ['year' => 2012]]);

How can I manipulate the post date in Ghost using the Momentjs 'add' function

I've just started a Ghost.org blog and I want the blog post dates to display one year ahead of when they were actually written. I know Ghost uses Moment.js and I am able to adjust formatting (DD MM YYYY, YY MM DD etc...) but it doesn't seem to accept the 'add' function described in the Moment.js docs.
This is the code I currently have.
<time datetime="{{date format="YYYY-MM-DD"}}">
{{date format='DD MMM YYYY'}}
</time>
To be clear, I want the blog post dates to remain accurate in ghost. I simply want to manipulate what gets DISPLAYED to the user as 1 year ahead.
EG. I write a blog post and it's post date is 20th Dec 2013. I want the date on the blog post to DISPLAY 20th Dec 2014.
The Ghost {{date}} helper does not seem to accept the 'add' function.
Any help would be really appreciated. I am still learning javascript, so there may be something obvious I'm missing. I apologise if that's the case.
I guess it's a bit late for you but it might help other people.
I found a way to edit the date in the casper view. It's more a hack than a real solution. But I wanted to be able to modify the date language without modifying the core. So here is my solution:
You need to add moment js in the casper template to do so you need to download it on the website and place it in the asset folder.
Place http://momentjs.com/downloads/moment-with-locales.min.js in /content/theme/casper/assets/js/
Then you need to call it in you /content/theme/casper/default.hbs
Add this line at the bottom of the file just before the index.js one.
<script type="text/javascript" src="{{asset "js/moment-with-locales.min.js"}}"></script>
Finally add this code in /content/theme/casper/assets/js/index.js just after the line
$document.ready(function () {
like this :
var dates = $('.post-date');
var i = 0;
var postDate = moment();
for(i=0;i<dates.length;i++){
postDate = moment(dates.eq(i).html());
postDate.add(1,'year');
dates.eq(i).html(postDate.format('LL'));
}

Using date variables outside Wordpress loop to display Adsense

I want to show adsense ads only on those posts and pages which are written in the year 2011 using variables outside the "loop". It there any way of doing it in wordpress ?
This can be accomplished by using variables in the Wordpress loop. The "loop" is commonly used for pulling data like this. This answer is only applicable if you plan to put the ad within the Wordpress loop.
This snippet of code can help you get started:
if(the_time('Y')=='2011') {
echo adsense_custom_function();
}
See more here: http://codex.wordpress.org/The_Loop_in_Action#Title.2C_Date_and_Author

How do I add taxonomy terms using Drupal Migrate

I'm using the migrate module to copy data from several sources to a new drupal installation. So far, I'm able to replicate a lot of what I need from the examples provided with the module. I'm currently stuck on adding terms or taxonomy to newly created nodes. The example shows:
// These are related terms, which by default will be looked up by name
$this->addFieldMapping('migrate_example_beer_styles', 'terms')
->separator(',');
I've tracked down the migrate_example_beer_styles destination mapping and it seems to be the machine name for that taxonomy.
I've tried imitating this behavior with every variation of what my machine_name should be, but the terms never seem to get associated:
By id:
// where source breed_id is '1,100' - it finds mapped values accordingly
$this->addFieldMapping('breeds', 'breed_id')
->sourceMigration('BreedMigration')
->separator(',')
And, by name:
// where source breeds is 'Dogs,German Shepherd'
$this->addFieldMapping('breeds', 'breeds')
->separator(',');
Am I wrong assuming the destination mapping is the machine name for a taxonomy?
This version of the migrate module was released recently, I haven't found any other helpful examples on the web.
This question still seems to be getting some views, so I thought I'd add what else I've discovered. While the accepted answer works, you are able to map Vocabs on ID:
$this->addFieldMapping('Exact Case Sensitive Vocab Name', 'source_field_name')
->sourceMigration('ExactSourceClassName')
->arguments(array('source_type' => 'tid'))
->separator(',');
->separator(',') used for passing a delimited string of source ids. Obviously, leave that off if you're mapping an array of values.
I'm currently working with migrate module myself, and I agree that the documentation is somewhat wanting at this point. :)
The 'machine name' of a vocabulary is listed in the Vocabulary table, in the field 'module'. Try using that value. Do note that you need to feed the text into the mapping, not the ids.
This is my first post on stackoverflow, so I apologize in advance if this isn't the accepted way to submit more information concerning this issue...
I've been stumbling around with the Migrate module for the past few days and was looking for a way to do this in Drupal 7. I had a comma-delimited list of taxonomy ids within an XML field that I wanted to use, but every example I found was retrieving from an external class, or from a database source.
Anyway, through trial and error, I found that you can use a field within the migrate class, rather than reference an external term migration class.
$this->addFieldMapping('field_article_type', 'category_id')
->arguments(array('source_type' => 'tid'))
->xpath('/article/category_id')
->separator(',');
Check out the taxonomy csv import module at http://drupal.org/project/taxonomy_csv.
It was easy to use and did what it was supposed to and more.
I ended up only using the migrate module for importin gNodes and used this module for the taxonomy. It was a pleasure to use.

Resources