0

Im kinda new to PHP so bear with me.

Im building a site for my uncle using the Fluxus Theme in Wordpress. He's an artist, his art is displayed in the following order:

Menu Category1
--Actual Art
--Actual Art
Category2
Category3
Category4

On his Actual Art page I want to create a link that goes back to the page where all the categories are shown. I've achieved the back link using href="../"

What I want is this to show

<a href="../">Go back to (Insert category of post here)</a>

So if the post has the project type: Funny art, it has to show "Go back to Funny art" and so on for every category.

What I have so far.

<aside class="widget widget-project-custom-info">
  <div class="decoration"></div>    
     <h3 class="widget-title"><a href="../">Go back to <?php echo $project_type; ?></a>
</aside>

$project-type , which is the category, doesn't want to show.

How can I achieve this? Again, im new to PHP and trying my best to understand this beautiful language.

Thanks In advance

Edit:

pastie.org/private/morjv8z3uiiwzhbb6wt0zq , this is the code from the project-type.php page? That might be useful? As the value for $project-type isn't called on the artwork page.

  • Please edit your question to include the code that you use to get the value for $project_type variable. – Mateusz Hajdziony Nov 19 '15 at 18:27
  • pastie.org/private/morjv8z3uiiwzhbb6wt0zq , this is the code from the project-type.php page? That might be useful? As the value for $project-type isn't called on the artwork page. – ginobrugman Nov 19 '15 at 19:53
  • I assume this should be something like: $project_type = blah blah blah – ginobrugman Nov 20 '15 at 18:49
  • Would this mean something? from class-portfolio-project.php ? function get_back_link() { if ( $this->meta_back_to_link ) { $project_type = get_term( $this->meta_back_to_link, 'fluxus-project-type' ); if ( $project_type ) { return get_term_link( $project_type, 'fluxus-project-type' ); } } return fluxus_get_default_portfolio_permalink(); } – ginobrugman Nov 20 '15 at 18:51
  • @MateuszHajdziony Would this help you to help me? – ginobrugman Nov 20 '15 at 19:07
0

It looks like the $project_type variable is not defined anywhere in the scope of your artwork page. You have to look into how to get the artwork's project type on the artwork page.

Is it a custom taxonomy? If yes, you would use functions like get_the_terms. I don't know what the project type taxonomy is called (how it was registered), so you will have to the the research on your own.

Maybe it is defined as post meta? In this case you would use get_post_meta function.

Whatever it is, once you get the term (or post meta) you can print its value using print_r( get_the_terms( $post->ID, 'taxonomy_name' ) ); to learn how the data is structured there and how to extract what you need from it (the taxonomy name and taxonomy link).

What you said in your last comment - it might be useful, yes, but it's hard to say without seeing the entire class. By the name of the function - it looks like it might get just the link to portfolio for you. I'm not sure if (and where) the class is instantiated so can't tell you for sure if you can use its functions on your artwork page. Again, can't help without seeing the code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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