# Display Posts Shortcode

The Display Posts Shortcode allows you to fine-tune the posts you wish to display on a page.

in a post or page, and use the arguments to query based on tag, category, post type, and many other possibilities.

New posts will be displayed within one hour of publishing.

#### Examples

This will list the 20 most recent posts with the tag ‘Advanced’.

This will list the 10 most recent posts tagged ‘Advanced’ and display a post image using the ‘Thumbnail’ size.

This will list every post in the Must Read category, in alphabetical order, with the date appended to the end.

This will display posts as an ordered list. Options are ul for unordered lists (default), ol for ordered lists, or div for divs.

This will display only the posts with an ID of 14 and 3.

#### Arguments

author
Specify the post author
Default: empty
Example:

category
Specify the category slug (or comma separated list of category slugs)
Default: empty
Example:

date_format
Specify the date format used when include_date is true. See Formatting Date and Time on the Codex for more information.
Default: ‘(n/j/Y)’
Example:

id
Specify a specific post ID (or multiple post IDs) to display.
Default: empty
Example:

image_size
Specify an image size for displaying the featured image, if the post has one. The image_size can be set to thumbnail, medium, large (all controlled from Settings > Media).
Default: empty
Example:

include_content
Include the full post content after the title.
Default: empty
Example:

• find closest points between two point set

point_set_1 =
20 482
19 359
45 438
61 248
90 403
104 95
149 335
148 392
161 73
186 29
188 236
189 319
200 162
208 70
204 198
203 343
214 250
225 307
233 171
238 205
237 245
253 148
264 362
281 34
300 341
306 88
305 203
328 234
326 164
330 20
364 199
424 241
433 314
491 187
point_set_2 =
99 399
104 95
149 335
148 392
158 82
184 238
190 320
202 343
236 246
263 361
299 342
330 20
493 193
%compute Euclidean distances:
for idx=1: length(point_set_1)
distances = sqrt(sum(bsxfun(@minus, point_set_2, point_set_1(idx,:)).^2,2));
%find the smallest distance and use that as an index into B:
closestForPin2toPin1(idx,:)= point_set_2(find(distances==min(distances)),:);
end

• foreign command atop frack or genfrac should be used instead(amsmath)

Using \atop is abusing its functionality; if you want to turn a screw, sometimes a knife can help, but a screwdriver is surely better.

In other words, use \substack that has been specifically defined for this task and can accommodate any number of lines. It’s also easier to use even for two lines.

\documentclass{article}
\usepackage{amsmath}

\begin{document}
$\sum_{1\le i\le n\atop i\ne j}\quad \sum_{\scriptstyle 1\le i\le n\atop\scriptstyle i\ne j}\quad \sum_{\substack{1\le i\le n\\ i\ne j}}$
\end{document}

The first is wrong; the second is complicated to write. With \substack you also avoid the warning

Package amsmath Warning: Foreign command \atop;
(amsmath)                \frac or \genfrac should be used instead
(amsmath)                 on input line 6.

https://tex.stackexchange.com/questions/153490/atop-vs-substack-for-multiple-lines-under-a-sum/153502

• Remove rows or cols whose elements are all NaN

For example,

A = [1 1 1 1 1 1 1 1 1 1;
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN;
1 1 1 1 1 1 1 1 1 1;
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN;];


should turned into

A = [1 1 1 1 1 1 1 1 1 1;
1 1 1 1 1 1 1 1 1 1];

Use this :

   out = A(:,any(~isnan(A)));  % for columns
out = A(any(~isnan(A),2),:);   %for rows

or

A(~any(~isnan(A), 2),:)=[];

• “Compared with” vs “Compared to”

Use “compared with” when you are looking for differences.

E.g. CEO’s now earn 419 times the pay of blue-collar workers, compared with 42 times their pay in the 1980’s.

Use “compared to” when highlighting (or comparing) the similarities of one thing to another.

E.g. The human heart can be compared to a pump.

https://english.stackexchange.com/questions/583/compared-with-vs-compared-to-which-is-used-when

• Change histogram to curve in Matlab but not “fit”

Instead of automatically plotting a histogram using hist, you can get it to output the values:

[x, c] = hist(radius1,400);

x is the data in each bin, c the centre of each bin, so this replicates a histogram and then overplots a line on it (which will just connect the top of each bar so it may not look as smooth as you hoped):

bar(c,x);
hold on
plot(c,x,'r');

It is possible to use fit with an anonymous function as a custom model, but that may be overkill in this situation.

https://stackoverflow.com/a/22452076/4862158

• Matlab: applying norm function to rows of matrix

Solution1

 norms = sqrt(sum(A.^2,1))

or

 norms = sqrt(sum(A.^2,2))?

depending on whether your coordinates are in rows or in columns.

Solution2

If readability is a bigger consideration than performance you might also consider:

norms = cellfun(@norm,num2cell(A,2));

This pattern is also adaptable to other operations along one dimension you might want to perform where MATLAB doesn’t support it natively.

Solution3

From version 2017b onwards, you can use vecnorm.

• get IEEEtran to work with the subcaption package

The problem is that there does not seem to be a way to prevent subcaption from taking control of the main caption formatting away from IEEEtran like the caption=false option does under subfig.sty. IEEEtran has to format captions differently depending on its mode. An admittedly crude hack that might work is simply to restore IEEEtran’s definition of \@makecaption:

\makeatletter
\let\MYcaption\@makecaption
\makeatother

\usepackage[font=footnotesize]{subcaption}

\makeatletter
\let\@makecaption\MYcaption
\makeatother

And then code figures like:

\begin{figure*}[!p]
\begin{minipage}[b]{0.5\linewidth}
\centering
\includegraphics[width=2.5in]{box}%
\subcaption{Case I}\label{fig_first_case}%
\end{minipage}%
\hfil
\begin{minipage}[b]{0.5\linewidth}
\centering
\includegraphics[width=2.5in]{box}%
\subcaption{Case II}\label{fig_second_case}%
\end{minipage}%
\caption{Simulation results for the network.}
\label{fig_sim}
\end{figure*}

This did seem to work for me in one simple test, but more extensive testing is required.

http://www.michaelshell.org/tex/ieeetran/

• Show \textwidth and \linewidth values in latex

Here’s a snippet you can paste into your latex document to reveal the values of \textwidth and \linewidth printed into your document. First include this in your header:


\usepackage{layouts}


textwidth: \printinunitsof{in}\prntlen{\textwidth}

linewidth: \printinunitsof{in}\prntlen{\linewidth}

http://www.alecjacobson.com/weblog/?p=2576

• The best way to place figures side-by-side in Latex

There are different way of placing figures side by side in Latex, subcaptionsubfigsubfigure, or even minipage. This post will tell you which one is the best.

## subcaption

A useful extension is the subcaption package (the subfigure and subfig packages are deprecated and shouldn’t be used any more), which uses subfloats within a single float. This gives the author the ability to have subfigures within figures, or subtables within table floats. Subfloats have their own caption, and an optional global caption. An example will best illustrate the usage of this package:

\usepackage{subcaption}
...
\begin{figure}
  \begin{subfigure}[b]{0.4\textwidth}
    \includegraphics[width=\textwidth]{1.png}
    \caption{Picture 1}
    \label{fig:1}
  \end{subfigure}
  %
  \begin{subfigure}[b]{0.4\textwidth}
    \includegraphics[width=\textwidth]{2.png}
    \caption{Picture 2}
    \label{fig:2}
  \end{subfigure}
\end{figure}

## minipage

The minipage can be used to place figures side-by-side too. But it is not a floating environment, thus has to be placed in a figure environment. Another disadvantage of minipage is that it does not align fi gures. Therefore, subcaption is still the best package you should use.

\begin{figure}
  \begin{minipage}[b]{0.4\textwidth}
    \includegraphics[width=\textwidth]{1.png}
    \caption{Picture 1}
    \label{fig:1}
  \end{minipage}
  \begin{minipage}[b]{0.4\textwidth}
    includegraphics[width=textwidth]{2.png}
    \caption{Picture 2}
    \label{fig:2}
  \end{minipage}
\end{figure}

subfig

## subfig and subfigure

Although subfig and subfigure packages are deprecated and shouldn’t be used any more, I will still provide two simple examples, to show you how to use them. Note: subfig support hyperref with BUGS!

usepackage{subfig}
...
begin{figure}[!ht]
  subfloat[Picture 1label{fig:1}]{%
    includegraphics[width=0.4textwidth]{1.png}
  }
  hfill
  subfloat[Picture 2label{fig:2}]{%
    includegraphics[width=0.4textwidth]{2.png}
  }
  caption{Main figure caption}
end{figure}

subfigure

usepackage{subfigure}
...
begin{figure}[ht]
  subfigure[Picture 1]{%
    includegraphics[width=.4textwidth]{1.png} label{fig:1}
  }
  quad
  subfigure[Picture 2]{%
    includegraphics[width=.4textwidth]{2.png} label{fig:2}
  }
  caption{Main figure caption}
end{figure}

http://blog.pengyifan.com/the-best-way-to-place-figures-side-by-side-in-latex/

• git This operation must be run in a work tree

you are probably inside the. git subfolder, move up one folder to your project root.

include_date
Include the post’s date after the post title. The default format is (7/30/12), but this can be customized using the ‘date_format’ parameter.
Default: empty
Example

include_excerpt
Include the post’s excerpt after the title (and date if provided).
Default: empty
Example:

• find closest points between two point set - point_set_1 = 20 482 19 359 45 438 61 248 90 403 104 95 149 335 148 392 161 73 186 29 188 236 189 319 200 162 208 70 204 198 203 343 214 250 225 307 233 171 238 205 237 245 253 148 264 362 281 34 300 341 306 88 305 […]
• foreign command atop frack or genfrac should be used instead(amsmath) - Using \atop is abusing its functionality; if you want to turn a screw, sometimes a knife can help, but a screwdriver is surely better. In other words, use \substack that has been specifically defined for this task and can accommodate any number of lines. It’s also easier to use even for two lines. \documentclass{article} \usepackage{amsmath} \begin{document} \[ \sum_{1\le i\le […]
• Remove rows or cols whose elements are all NaN - For example, A = [1 1 1 1 1 1 1 1 1 1; NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN; 1 1 1 1 1 1 1 1 1 1; NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN;]; should turned into A = [1 1 1 1 1 1 […]
• “Compared with” vs “Compared to” - Use “compared with” when you are looking for differences. E.g. CEO’s now earn 419 times the pay of blue-collar workers, compared with 42 times their pay in the 1980’s. Use “compared to” when highlighting (or comparing) the similarities of one thing to another. E.g. The human heart can be compared to a pump. https://english.stackexchange.com/questions/583/compared-with-vs-compared-to-which-is-used-when
• Change histogram to curve in Matlab but not “fit” - Instead of automatically plotting a histogram using hist, you can get it to output the values: [x, c] = hist(radius1,400); x is the data in each bin, c the centre of each bin, so this replicates a histogram and then overplots a line on it (which will just connect the top of each bar so it may not look […]
• Matlab: applying norm function to rows of matrix - Solution1 norms = sqrt(sum(A.^2,1)) or norms = sqrt(sum(A.^2,2))? depending on whether your coordinates are in rows or in columns. Solution2 If readability is a bigger consideration than performance you might also consider: norms = cellfun(@norm,num2cell(A,2)); This pattern is also adaptable to other operations along one dimension you might want to perform where MATLAB doesn’t support […]
• get IEEEtran to work with the subcaption package - The problem is that there does not seem to be a way to prevent subcaption from taking control of the main caption formatting away from IEEEtran like the caption=false option does under subfig.sty. IEEEtran has to format captions differently depending on its mode. An admittedly crude hack that might work is simply to restore IEEEtran’s definition of \@makecaption: […]
• Show \textwidth and \linewidth values in latex - Here’s a snippet you can paste into your latex document to reveal the values of \textwidth and \linewidth printed into your document. First include this in your header: \usepackage{layouts} Then in your content someplace: textwidth: \printinunitsof{in}\prntlen{\textwidth} linewidth: \printinunitsof{in}\prntlen{\linewidth} http://www.alecjacobson.com/weblog/?p=2576
• The best way to place figures side-by-side in Latex - There are different way of placing figures side by side in Latex, subcaption, subfig, subfigure, or even minipage. This post will tell you which one is the best. subcaption A useful extension is the subcaption package (the subfigure and subfig packages are deprecated and shouldn’t be used any more), which uses subfloats within a single float. This gives the author the ability to have subfigures […]
• git This operation must be run in a work tree - you are probably inside the. git subfolder, move up one folder to your project root.   https://ask.helplib.com/c/949761

offset
The number of posts to pass over
Default: 0
Example:

order
Specify whether posts are ordered in descending order (DESC) or ascending order (ASC).
Default: DESC
Example:

orderby
Specify what the posts are ordered by. See the available parameters here.
Default: date
Example:

portfolio_type
If you are using the Portfolio post type, use this to get items from a specific portfolio type.

post_parent
Display the pages that are a child of a certain page. You can either specify an ID or ‘current’, which displays the children of the current page.
Default: empty
Example:

post_status
Show posts associated with a certain post status
Default: publish
Example:

post_type
Specify which post type to use. You can use a default one (post or page). For Portfolios use “jetpack-portfolio”.  Similarly, for Testimonials use “jetpack-testimonial”.
Default: post
Example:

posts_per_page
How many posts to display.
Default: 10
Example:

tag
Specify the tag slug (or comma separated list of tag slugs)
Default: empty
Example:

taxonomy, tax_term, and tax_operator
Use these parameters to do advanced taxonomy queries. Use ‘taxonomy’ for the taxonomy you’d like to query, ‘tax_term’ for the term slug (or terms) you’d like to include, and ‘operator’ to change how the query uses those terms (most likely this field will not be needed).
Default: ‘taxonomy’ = empty , ‘tax_term’ = empty , ‘tax_operator’ = ‘IN’
Example:

wrapper
What type of HTML should be used to display the listings. It can be an unordered list (ul), ordered list (ol), or divs (div) which you can then style yourself.
Default: ul
Example:

#### Multiple Taxonomy Queries

While most people will only ever need a single taxonomy query, this shortcode supports an infinite number of taxonomy queries. Let’s say you wanted to get all posts in category “featured” and also tagged “homepage”. We’ll use a shortcode that looks like this:

You can string as many of those as you like, just start the count at 2. In the field listing below, replace (count) with an actual number.

Here’s the available fields:

taxonomy_(count)
Which taxonomy to query
Default: empty

tax_(count)_term
Which terms to include (if more than one, separate with commas)
Default: empty

tax_(count)_operator
How to query the terms (IN, NOT IN, or AND)
Default: IN

tax_relation
Describe the relationship between the multiple taxonomy queries (should the results match all the queries or just one of them). Available options: AND and OR
Default: AND

#### Image Alignment

A common request is display a list of posts with title, excerpt, and the thumbnail aligned to the right. Here’s the shortcode you might use:

find closest points between two point set - point_set_1 = 20 482 19 359 45 438 61 248 90 403 104 95 149 335 148 392 161 73 186 29 188 236 189 319 200 162 208 70 204 198 203 343 214 250 225 307 233 171 238 205 237 245 253 148 264 362 281 34 300 341 306 88 305 […]
foreign command atop frack or genfrac should be used instead(amsmath) - Using \atop is abusing its functionality; if you want to turn a screw, sometimes a knife can help, but a screwdriver is surely better. In other words, use \substack that has been specifically defined for this task and can accommodate any number of lines. It’s also easier to use even for two lines. \documentclass{article} \usepackage{amsmath} \begin{document} \[ \sum_{1\le i\le […]
Remove rows or cols whose elements are all NaN - For example, A = [1 1 1 1 1 1 1 1 1 1; NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN; 1 1 1 1 1 1 1 1 1 1; NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN;]; should turned into A = [1 1 1 1 1 1 […]
“Compared with” vs “Compared to” - Use “compared with” when you are looking for differences. E.g. CEO’s now earn 419 times the pay of blue-collar workers, compared with 42 times their pay in the 1980’s. Use “compared to” when highlighting (or comparing) the similarities of one thing to another. E.g. The human heart can be compared to a pump. https://english.stackexchange.com/questions/583/compared-with-vs-compared-to-which-is-used-when
Change histogram to curve in Matlab but not “fit” - Instead of automatically plotting a histogram using hist, you can get it to output the values: [x, c] = hist(radius1,400); x is the data in each bin, c the centre of each bin, so this replicates a histogram and then overplots a line on it (which will just connect the top of each bar so it may not look […]
Matlab: applying norm function to rows of matrix - Solution1 norms = sqrt(sum(A.^2,1)) or norms = sqrt(sum(A.^2,2))? depending on whether your coordinates are in rows or in columns. Solution2 If readability is a bigger consideration than performance you might also consider: norms = cellfun(@norm,num2cell(A,2)); This pattern is also adaptable to other operations along one dimension you might want to perform where MATLAB doesn’t support […]
get IEEEtran to work with the subcaption package - The problem is that there does not seem to be a way to prevent subcaption from taking control of the main caption formatting away from IEEEtran like the caption=false option does under subfig.sty. IEEEtran has to format captions differently depending on its mode. An admittedly crude hack that might work is simply to restore IEEEtran’s definition of \@makecaption: […]
Show \textwidth and \linewidth values in latex - Here’s a snippet you can paste into your latex document to reveal the values of \textwidth and \linewidth printed into your document. First include this in your header: \usepackage{layouts} Then in your content someplace: textwidth: \printinunitsof{in}\prntlen{\textwidth} linewidth: \printinunitsof{in}\prntlen{\linewidth} http://www.alecjacobson.com/weblog/?p=2576
The best way to place figures side-by-side in Latex - There are different way of placing figures side by side in Latex, subcaption, subfig, subfigure, or even minipage. This post will tell you which one is the best. subcaption A useful extension is the subcaption package (the subfigure and subfig packages are deprecated and shouldn’t be used any more), which uses subfloats within a single float. This gives the author the ability to have subfigures […]
git This operation must be run in a work tree - you are probably inside the. git subfolder, move up one folder to your project root.   https://ask.helplib.com/c/949761

This includes the excerpt, adds an image of the “thumbnail” size (you can customize the image sizes in Settings > Media), and tells it to present the list without bullets.

.display-posts-listing .alignleft {
float: right;
margin: 0 0 5px 5px;
}