Function Reference: get_publications - winkm89/teachPress GitHub Wiki
Description
This function returns an array or an object of publications. It's the general API function for getting publication data.
Usage
$array = TP_Publications::get_publications( $args, $count = false );
You can set $count to true if you want to receive only the number of publications.
Default Usage
$defaults = array(
'user' => '',
'type' => '',
'tag' => '',
'key' => '',
'author_id' => '',
'import_id' => '',
'year' => '',
'author' => '',
'editor' => '',
'include' => '',
'include_editor_as_author' => true,
'exclude' => '',
'exclude_tags' => '',
'exclude_types' => '',
'order' => 'date DESC',
'limit' => '',
'search' => '',
'meta_key_search' => array(),
'output_type' => OBJECT
);
$array = TP_Publications::get_publications( $args, $count = false );
Parameters for $args
user
(integer) The ID of the user whose publications you want to show. You can separate more than one by comma.
type
(string) The publication types you want to show. You can separate more than one by comma.
tag
(string) If you want to display only publications with a determined tag, so set with this parameter the tag-ID of this tag. You can separate more than one by comma.
new since 6.0.0
key (string) If you want to display only publications with a determined bibtex key. You can separate more than one by comma.
year
(string) If you want to display only publications with a determined year, so set it with this parameter. You can separate more than one by comma.
author
(string) If you want to display only publications with a determined author. You can separate more than one author name by comma.
author_id
(string) If you want to display only publications with a determined author. You can separate more than one author ID my comma.
import_id
(string) If you want to display only publications with a determined import ID. You can separate more than one import ID my comma.
editor
(string) If you want to display only publications with a determined editor. You can separate more than one editor name by comma.
exclude
(string) Define a comma-separated list of publication IDs to be excluded from the list.
exclude_tags
(string) Use it to exclude publications via tag IDs (separated by comma)
exclude_types
(string) Use it to exclude publications via types (separated by comma)
include
(string) Define a comma-separated list of publication IDs to be included from the list.
include_editor_as_author
(BOOL) True or false. Default: true.
order
(string) Change the order of the list.
limit
(string) Limits the number of publications. Example: „0,30“ for the first 30 entries;
search
(string) Use this parameter for a search over names, booktitles, authors, editors, journals, years and isbns.
new since 8.0.0
meta_key_search (Array) An array which contains the parameters for meta_keys as key=>value pair.
Example for an checkbox:
meta_key_search => array( 'tp_meta_pub_custom_label' => '{Open Access}' )
output_type
(string) You can choice between:
OBJECT (default) ARRAY_A ARRAY_N
Return
(array or object)
An array or object containing all the publications matching the request
The fields returned for each row are:
pub_id
(integer) ID of the publication
title
(string) Title of the publication
type
(string) Type of the publication
bibtex
(string) BibTeX key of the publication
author
(string) The name(s) of the author(s) (in the case of more than one author, separated by and)
editor
(string) The name(s) of the editor(s) (in the case of more than one editor, separated by and)
date
(string) Date of publishing (YYYY-MM-DD)
year
(string) Year of publishing (YYYY)
urldate
(string) Date of visiting (YYYY-MM-DD)
isbn
(string) The ISBN/ISSN number
url
(string) Some URLs
booktitle
(string) The title of the book, if only part of it is being cited
journal
(string) The journal or magazine the work was published in.
volume
(string) Volume of the journal where the work was published
number
(string) Number of the journal where the work was published
pages
(string) Page numbers
publisher
(string) Name of the publisher
address
(string) Publisher’s address (usually just the city, but can be the full address for lesser-known publishers)
edition
(string) Edition of the resource where the publication can be found
chapter
(string) Chapter of the resource where the publication can be found
institution
(string) The institution that was involved in the publishing, but not necessarily the publisher
organization
(string) The conference sponsor
school
(string) The school where the thesis was written
series
(string) The series of books the book was published in
crossref
(string) The key of the cross-referenced entry
abstract
(string) The abstract of the work
howpublished
(string) How it was published, if the publishing method is nonstandard
key
(string) A hidden field used for specifying or overriding the alphabetical order of entries.
techtype
(string) Additional type of publication (e.g. „Research Note“ for techreport, „{PhD} dissertation“ for phdthesis, „Section“ for inbook/incollection)
note
(string) Miscellaneous extra information
is_isbn
(integer) Says if the type of the number in the isbn field is a ISBN or ISSN number (1|0)
image_url
(string) URL of a publication image
rel_page
(integer) ID of a WordPress post or page
doi
(string) The DOI number of a publication
status
(string) The status of publishing (for example: published)
added
(integer) The date where the publication entry was added
modified
(integer) The date where the publication entry was modified at last
[Optional: Custom meta data]
The method also returns the values for custom meta data
Example
Get all articles and inproceedings:
$publications = TP_Publications::get_publications( array('type' => 'article, inproceedings') );
foreach ($publications as $row) {
// put your code here
}
Get the number of publications which are published in 2019 and 2020:
$args = array( 'year' => '2019,2020' );
$number = TP_Publications::get_publications($args, true);
Changelog
- Since: 5.0.0