Have wp_get_archives return a string with no year in it - wordpress

Currently I use wp_get_archives to return the year.
I then call it again with the monthly arg to display the months.
It displays similarly to this, though I am not sure it will work when we are in a different year:
2011
April 2011(1)
March 2011(12)
I want a display like this
2012(when we reach it)
December(8)
November(5)
2011
April(1)
March(12)
Where the number in brackets is the months post count.
Obviously this means stripping out the year from the monthly archives.
Is this possible? I'd rather not modify core wp functions and do this within the theme, I would also rather not rely on a plugin.
Thank you!

While maybe not the best way to do it, give this a try
$string = wp_get_archives('type=monthly&limit=20&echo=0');
$pattern = ' ((19|20)\d{2}(</a>))';
echo preg_replace($pattern, '\\3', $string);

Related

How to import data from csv file in which comma used instead decimal point in prices using wp all import?

I am using wp all import to import products. My all prices are with comma instead of decimal point(.). When I use condition to get all product which price less than 11,5 it returns zero result. It could not recognise comma.
This is an old post 2 years ago, but propably someone is looking for a solution. Thus, you could add a custom function inside Regular Price (or wherever you want to place this price value). For example, add this code:
[check_price({column_of_your_csv[1]})]
and inside Function Editor tab, you could write this code:
function check_price($avail) {
$price = str_replace(",",".",$avail);
return $price;
}
Not tested, but it should work!

How to add a specific number of days (+1 day) to current date in (ISO & RFC format) for "WordPress"?

I have been searching for a long time to find out how easily to add a specific number of days (+1 day) to current date in (ISO & RFC format) for "WordPress"?
Anyway, After tons of testings and failure I came up with the final solution.
Solution:
First of all, We must get the default current post date (get_the_date), Then add the desired format (ISO or RFC), and finally increase it by adding more +days to it as follow:
<?php
$Date = get_the_date('Y-m-d');
echo date('c', strtotime($Date. ' + 10 days'));
?>
The results will be:
- Current date: 2018-09-14
- Increased date: 2018-09-24T00:00:00+00:00 *(with ISO format)*.
This achievement can be useful when you want to validate sitemap, Wordpress feed, or add schema markup to your pages (manually).
Hope this can help you :)

Edit a data item in Cognos to display as two digits

Disclaimer: I am a Cognos newbie.
I want to format a data item in Cognos (Report Studio 10.2) to always display as 2 digits. For example, if the value of the data item in 2, I want it to be displayed as 02. How can I achieve this?
I have tried
Format$([my_data_item], "00")
Format([my_data_item], '00') - w/o the dollar sign
None worked.
Any help will be highly appreciated. Thanks!
Marcus ...thanks for pointing me in the right direction.
I was able to use the round function in the query with a CASE statement and it served my purpose with very little modification to the original report. Note to any new Cognos developer would be leave formatting to the report page and not the query.
case when [TRANSFORMATION VIEW].[SOME_FACT].[DOLLAR_VAL]<>-99999 then
case when [TRANSFORMATION VIEW].[SOME_FACT].[DOLLAR_VAL] >= 1000000 then
round( [TRANSFORMATION VIEW].[SOME_FACT].[DOLLAR_VAL] /1000000, 2)
else
round([TRANSFORMATION VIEW].[SOME_FACT].[DOLLAR_VAL],0)
end
end
Then on the report itself, I formatted the data item as Numeric and didn't change any of the default settings. That did the magic. The reason why I have round([TRANSFORMATION VIEW].[SOME_FACT].[DOLLAR_VAL],0) is because I don't want to display cents in the dollar amount.

What data notation is this?

I came across this chunk of data while going through a theme's metadata in wordpress. It looks like instead of using several metadata keys for different bits of data, they smooshed it all together in one chunk. This in particular is meta data for an event post type:
a:3:{s:8:"dateFrom";s:16:"Mon, 10 Feb 2014";s:6:"dateTo";s:16:"Mon, 10 Feb 2014";s:8:"location";s:87:"Convention Center";}"
I mostly just want to extract "dateFrom" so I can display it in a widget.
It looks like for other events the only things that change are the actual values (dates, location). The parts that are [a-z]:[0-9]* (which seem to be keys, but they aren't valid JSON keys cause of the colons) are constant.
That value is PHP serialized. If you unserialize it it'll be converted to an array. So something like (untested):
$orig = 'a:3:{s:8:"dateFrom";s:16:"Mon, 10 Feb 2014";s:6:"dateTo";s:16:"Mon, 10 Feb 2014";s:8:"location";s:87:"Convention Center";}"';
$converted = unserialize($orig);
echo $converted['dateFrom'];
should do the trick

drupal7 change format of comment's $created

I have been trying for some time now to reformat the date that appears below the avatar when a comment is made to a blog post.
I have found no way of doing it through any settings, so I have moved over to the template files. Changing the date format of the original blog post was easy, but with comments, no variable holding the date in raw (unix) format is passed in to the template, so I can't reformat and extract the pieces of the date that I want.
The Zen theme help note says:
* - $created: Formatted date and time for when the comment was
created.
I would like to reformat this from
Tue, 2011-09-13 11:57
Into two separate variables,
13 Sep, 2011
11:57
any idéas? Thanks
In your template file you should have access to the $node variable so you can do something like this:
echo date('j M, Y H:i', $node->created);
See the PHP date page for information on the format string used above.

Resources