Show all posts from category X with the same taxonomy term as current post - categories

I already have this almost working, with a neat snippet someone helped me with. Currently though its displaying all posts regardless of category or post type with the same taxonomy term as the current post. I would like to change it so I can specify which category it should loop in the posts from.
This is what the code looks like:
http://pastebin.com/pM8aFPQ9
I realise this is probably pretty easy to do, but I dont know where in this code I should specify the categories or how I should write to do that. Can anyone help me with this?

I used your code to solve the same problem and I filtered the posts with info from:
http://codex.wordpress.org/Class_Reference/WP_Query
Using the info on that page, in the $args that you specify, you can add 'post_type' => array('custom_post_type_01', 'custom_post_type_02');
You could also specify which categories to include (or exclude) using this code:
'category_name' => 'category';
You can find more info on the page above and you can essentially filter your posts using lots of different parameters. Hope this helps!

Related

google adslot syntax - is there a way to not specify a criteria?

I am trying to introduce interstitial adverts for a web project but I am confused about how to use an existing adslot without defining a criteria for that (or if it is even possible?)
From the documentation here:
https://developers.google.com/publisher-tag/reference
https://developers.google.com/publisher-tag/guides/key-value-targeting
There are some examples that show a chosen category of advert to be shown, for example:
googletag.defineSlot('/1234567/sports', [728, 90], 'div-1');
or
googletag.defineOutOfPageSlot('/6355419/Travel/Europe/France/Paris',
googletag.enums.OutOfPageFormat.INTERSTITIAL);
when I try to use the sample code with my account ID and the ad-unit name, it does not work. I don't want to define cateogries at this stage, I would prefer that it is done automatically.
For example
interstitialSlot = googletag.defineOutOfPageSlot('/26*****997/auto',
googletag.enums.OutOfPageFormat.INTERSTITIAL);
or
interstitialSlot = googletag.defineOutOfPageSlot('/26*****997/interstitial-unit-name',
googletag.enums.OutOfPageFormat.INTERSTITIAL);
but neither of these formats are accepted and the documentation seems to be somewhat lacking in other examples.
Any help appreciated.
interstitialSlot = googletag.defineOutOfPageSlot('/26*****997/auto',
googletag.enums.OutOfPageFormat.INTERSTITIAL);
Use this and wait 24 hours only

Protractor Implementation in Angular2 without using ids

I have application in Angularjs2, and developers have not been using ids into it. Now I have to implement the Protractor on same application. Is there anyway to implement the Protractor without using "absolute XPath"?
Thanks in advance!
Please find a huge range of locator-possibilities on the official Protractortest API Page
Every element on a page needs to be uniquely identifiable... else the page wouldn't work, no matter which technology. Therefore with the help of any of the above provided locator-possibilities you'll always find the element you're looking for.
And there is never a need for XPath, except for this only one. (though there is an parentElementArrayFinder introduced in the meantime, so not even that one exception is valid anymore)
UDPATE
If you could use XPath, you can for sure use CSS-Locators.
Here some examples for locators:
$('div.class#id[anyAttribute="anyValue"] div.child.somewhere-below-div-point-class')
element(by.cssContainingText('div[data-index="2"]', 'select this option'))
Or as a specific example the "Learn More" of the "Tree List" section of https://js.devexpress.com/ :
treeListSection = element(by.cssContainingText('div.tab-content h2', 'Tree List')).getDriver();
learnMoreBtn = treeListSection.element(by.cssContainingText('a.tab-button','Learn More'));
learnMoreBtn.click();
Those are just examples, but there is always a way to do it.
If you provide some example-HTML in your Question, I can direct you towards a solution.
UPDATE 2
For getting the Parent Web Element, one could use getDriver() as well

In the qbXML ItemQuery request , how do I get the description for a service item?

I am creating a tool that will synchronize our production database with QuickBooks (QB). I am trying to get a list of all the items in QB using ItemQuery and I want to get the description of each item as well. However, it seems that different types of items have different ways of specifying the description. Using IncludeRetElement, I am able to get the SalesDesc for ItemInventoryRet, but I am struggling with getting the description for ItemServiceRet (and a few others, but I think if I can figure this one out, I will be able to figure out the others).
Here is my request...
<?qbxml version="12.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<ItemQueryRq requestID="2">
<IncludeRetElement>ListID</IncludeRetElement>
<IncludeRetElement>Name</IncludeRetElement>
<IncludeRetElement>FullName</IncludeRetElement>
<IncludeRetElement>ParentRef</IncludeRetElement>
<IncludeRetElement>SalesAndPurchase_SalesDesc</IncludeRetElement>
<IncludeRetElement>SalesOrPurchase_Desc</IncludeRetElement>
<IncludeRetElement>ItemDesc</IncludeRetElement>
<IncludeRetElement>SalesDesc</IncludeRetElement>
</ItemQueryRq>
</QBXMLMsgsRq>
</QBXML>
And here is the response I'm getting (shortened for clarity)...
<QBXML>
<QBXMLMsgsRs>
<ItemQueryRs requestID="2" statusCode="0" statusSeverity="Info" statusMessage="Status OK">
<ItemServiceRet>
<ListID>240000-1071531214</ListID>
<Name>Delivery</Name>
<FullName>Delivery</FullName>
</ItemServiceRet>
<ItemInventoryRet>
<ListID>270000-1071524193</ListID>
<Name>1/2" Line</Name>
<FullName>Irrigation Hose:1/2" Line</FullName>
<SalesDesc>1/2" Vinyl Irrigation Line</SalesDesc>
</ItemInventoryRet>
<ItemGroupRet>
<ListID>1E0000-934380927</ListID>
<Name>Walkway</Name>
<ItemDesc>Walkway lighting</ItemDesc>
</ItemGroupRet>
</ItemQueryRs>
</QBXMLMsgsRs>
</QBXML>
According to the documentation (pick ItemQuery from the dropdown), the description I think I want is ItemServiceRet > ORSalePurchase > SaleOrPurchase > Desc. The request includes one way I've tried, but I've tried quite a few other ways as well...
<IncludeRetElement>ORSalesPurchase:SalesOrPurchase:Desc</IncludeRetElement>
<IncludeRetElement>ORSalesPurchase.SalesOrPurchase.Desc</IncludeRetElement>
<IncludeRetElement>ORSalesPurchase_SalesOrPurchase_Desc</IncludeRetElement>
<IncludeRetElement>SalesOrPurchase:Desc</IncludeRetElement>
<IncludeRetElement>SalesOrPurchase.Desc</IncludeRetElement>
<IncludeRetElement>SalesOrPurchase_Desc</IncludeRetElement>
<IncludeRetElement>Desc</IncludeRetElement>
So the question is, how do you retrieve sub elements in qbXML queries?
I have found that if I remove all the IncludeRetElements, I do get the values. But I would like to learn how to only get the data I care about. We have a HUGE QB database so this could be a major performance issue if I have to get everything.
As a note, I switched to using QBFC10Lib instead of creating the XML myself hoping it would help me solve this issue, but it didn't. I am still having the exact same issue. I'm guessing that an answer to one will resolve both qbXML and QBFC.
I figured it out. You have to add each level separately, like this...
<?qbxml version="12.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<ItemQueryRq requestID="2">
<IncludeRetElement>ListID</IncludeRetElement>
<IncludeRetElement>Name</IncludeRetElement>
<IncludeRetElement>FullName</IncludeRetElement>
<IncludeRetElement>ItemDesc</IncludeRetElement>
<IncludeRetElement>SalesDesc</IncludeRetElement>
<IncludeRetElement>ORSalesPurchase</IncludeRetElement>
<IncludeRetElement>SalesOrPurchase</IncludeRetElement>
<IncludeRetElement>SalesAndPurchase</IncludeRetElement>
<IncludeRetElement>Desc</IncludeRetElement>
</ItemQueryRq>
</QBXMLMsgsRq>
</QBXML>
I had tried this earlier, but I think I missed a level. Anyway, hopefully this answer will help somebody else from wasting half their day :).

RESTful urls for restore operation from a trash bin

I've been implementing a RESTful web service which has these operations:
List articles:
GET /articles
Delete articles (which should remove only selected articles to a trash bin):
DELETE /articles
List articles in the trash bin:
GET /trash/articles
I have to implement an operation for restoring "articles" from "/trash/articles" back to "/articles".
And here is the question. Ho do you usually do it? What url do I have to use?
I came up to the 2 ways of doing it. The first is:
DELETE /trash/articles
But it feels strange and a user can read it like "delete it permanently, don't restore".
And the second way is
PUT /trash/articles
Which is more odd and a user will be confused what this operation does.
I'm new to REST, so please advice how you do it normally. I tried to search in google but I don't know how to ask it right, so I didn't get something useful.
Another option could be to use "query params" to define a "complementary action/verb" to cover this "special condition" you have (given that this is not very easily covered by the HTTP verbs). This then could be done for example by:
PUT /trash/articles?restore=true
This would make the URI path still complaint with REST guideline (referring to a resource, and not encoding "actions" - like "restore") and would shift the "extra semantics" of what you want to do (which is a very special situation) to the "query parameter". "Query params" are very commonly used for "filtering" resources in REST, not so much for this kind of situation... but maybe this is a reasonable assumption given your requirements.
I would recommend using
PUT /restore/articles
or
PUT /restore/trash/articles
Late answer but, in my opinion, the best way is to change the resource itself.
For instance:
<article is_in_trash="true">
<title>come title</title>
<body>the article body</body>
<date>1990-01-01</date>
</article>
So, in order to remove the article from Trash, you would simple use PUT an updated version of the article, where is_in_trash="false".

Trying to figure out what {s: ;} tags mean and where they come from

I am working on migrating posts from the RightNow infrastructure to another service called ZenDesk. I noticed that whenever users added files or even URL links, when I pull the xml data from RightNow it gives me a lot of weird codes like this:
{s:3:""url"";s:45:""/files/56f5be6c1/MUG_presso.pdf"";s:4:""name"";s:27:""MUG presso.pdf"";s:4:""size"";s:5:""2.1MB"";}
It wasn't too hard to write something that parses them and makes normal urls and links, but I was just wondering if this is something specific to the RightNow service, or if it is a tag system that is used. I tried googling for this but am getting some weird results so, thought stack overflow might have someone who has run into this one.
So, anyone know what these {s ;} tags are called and if there are any particular tools to use to read them?
Any answers appreciated!
This resembles partial PHP serialized data, as returned by the serialize() call. It looks like someone may have turned each " into "", which could prevent it from parsing properly. If it's wrapped with text like this before the {s: section, it's almost definitely PHP.
a:6:{i:1;a:10:{s:
These letters/numbers mean things like "an array with six elements follows", "a string of length 20 follows", etc.
You can use any PHP instance with unserialize() to handle the data. If those double-quotes are indeed returned by the API, you might need to replace :"" and ""; with " before parsing.
Parsing modules exist for other languages like Python. You can find more information in this answer.