Web Hosting
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: Interconección entre woocommerce y portfolio

Discussion in 'Misc WordPress Requests' started by bcworkz, Nov 14, 2017 at 11:26 AM.

  1. bcworkz


    Reply To: Interconección entre woocommerce y portfolio, by bcworkz

    Welcome to the forums. I hope replies in English are useful for you. You may continue using Spanish if you prefer. If you prefer an all Spanish conversation, you should consider the Spanish language Forums.

    You need to make custom queries to get portfolios containing particular tags. The query results can be output using the standard Loop. There are a couple ways to make custom queries, I recommend creating a custom page template. Changing templates means creating a child theme. This protects your work from theme updates. Any other customizations you may develop can be contained in your child theme as well.

    Copy your theme’s page.php template to your child’s folder, giving it a new file name. Alter the comment header to contain the Template Name: line like the example in the above page template link. Add code to make a custom query that includes tag parameters. You could specify the actual tag term based on an URL parameter, a custom permalink, or the page name requested.

    Alter the Loop code to use object methods instead of template tags. For example, if your new query object is assigned to $the_query, where your template’s loop code calls have_posts(), change it to $the_query->have_posts(). Also change the_post() to $the_query->the_post(). Scroll up from the tag parameter link for example loop code. If your theme’s page.php does not have a Loop, it is on an external template part. If so, copy that file to your child as well, giving it a new name. Change the get_template_part() parameter to reference the new name. Make the loop changes to this copy.

    Add a new page to your site, specifying your custom template as the page’s template. You only need to give the new page a title so there is a permalink to get the page with. There is no need for content, it is ignored by the template I’ve described. You could add another page for each different tag you want to query with. Use the same template for all. The tag query parameter would then be determined by the page requested. You can get the requested page slug from global $wp_query->query['pagename']. PHP’s switch/case structure is good for relating several page names to tag parameters.

    I hope this all is understandable and makes sense to you.

    Reply To: Interconección entre woocommerce y portfolio

Share This Page

Web Hosting