I want to show some content based by tags of a user, that is how i would like to do it, but it did not work:

$args = array($arg1,$arg2,$argn);

function show_tag_content($path){
  $post = get_page_by_path($path);
  $content = apply_filters('the_content', $post->post_content);
  echo $content;

for ($i = 0; i<count($args);$i++){
show_tag_content('blog/tag/' . $args[$i]);

tried the function with a hard string without using blog and more than one page content, e. g.:


works perfect, tried it that way:



Need some help here at this point

  • Any error? try var_dump($post); after using get_page_by_path($path); to see what is the function returning.
    – David Lee
    Feb 13, 2017 at 16:32

1 Answer 1


in case someone else in searching for this, I used a WP Query with the statement tag:

$args = array (myargs1,....,myargsn);
for ($i=0; $i<count($args);$i++){
$query = new WP_Query( array( 'tag' => $args[$i] ) );

...and so on with if have_posts() and a while loop, you can find the whole syntax on wordpress.org, only thing i did working with a for-loop to run run my array

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.