I need to change a wp plugin to choose another taxonomy according to the page that i use it - wordpress

I am using the post-grid-and-filter-ultimate plugin to create some filters.
I am also using a plugin to create custom taxonomies.
I have created 5 different blog pages where i need to display different filters
1st page is using the taxonomy vegan which have filters burger, pizza etc
2nd page is using taxonomy vegetarian which have filters burger, pizza etc
and so on.
I would like the plugin to read different taxonomy for every page.
This one here
if( !defined( 'PGAFU_CAT' ) ) {
define( 'PGAFU_CAT', 'vegan_dish' );
}
defines the category/taxonomy.
For blogpage with title "vegan places" it should read the taxonomy "vegan_dish". For blog page with title "vegetarian places" it skould read the taxonomy "vegetarian_dish" and so on.
I believe that this could be done with a "for" but dont know how to let it read the page titles/ids of wordpress
Any ideas?
Thanks in advance

Related

How to add a child page to a Custom Post Type "Post"

Friends, Hello.
I have an issue, i'm searching for an answer for 2 days now. I think I have checked all the 10 firsts google pages of 20 different requests by now.
So, this is it.
I have a custom post type named "Footballer".
I have created 2 "Posts" of that CPT, which are "Messi" and "Ronaldo".
My permalinks for these 2 footballers are "mysite.com/footballer/messi/" and "mysite.com/footballer/ronaldo/". It is OK for me.
Now, I want to add a child page "about" (or "stats", or anything) to my footballers and I want this page to be available by the link "mysite.com/footballer/messi/about" (just add the child page slug after the cpt post link).
Obviously, I want to create a single page "about", not one for every footballer I have, and in this page I would retrieve data for the specific footballer (by functions/shortcodes).
Nota: the cpt and values in this post are fictionnals, I know I would display the about/stats directly in the footballer cpt post. I am just trying to explain what I need -> a generic child page for a cpt, available by "mysite.com/cpt/cptpost/childpage".
How can I do it ? I s it even possible ?
Thanks for your help.
EDIT ;
As it is not possible with Divi, can I try to rewrite the URL of my subpage ? If my subpage url is "mysite/subpage/?foot=messi", can I make it appear "mysite/footballer/messi/subpage".
I tried this code, without success
function my_rewrite_url() {
add_rewrite_tag( '%foot%','([^&]+)' );
add_rewrite_rule(
'footballer/([^/]+)/subpage',
'index.php?pagename=subpage&foot=$matches[1]',
'top'
);
}
add_action( 'init', 'my_rewrite_url' );
You are looking for custom taxonomies on the custom post type.

Page Template for every custom post type

I'm just new in wordpress, I just wanted to ask if it's a bad practice if I'll create page template for every custom post types?
I mean if I have CPT [custom post type] with different content, like my first CPT has images, my 2nd cpt has image and text, my last CPT, has slider, text and description.
Because I wanted to create page template for every type of CPT's I have. Is it a bad practice? Or are there efficient and effective ways to do such things?
Your answers are highly appreciated. Thanks!
It's better not to do that, not only because it's a server load, but also because you'll get crazy if you have an issue. Instead, use conditionals in the same page. You can read about it at WP Codex: Conditional Tags : Taxonomies and then pay attention to the is_tax and has_term tags.
This way, you can use is_tag or has_term depending on your approach, like this
if( has_term( 'jazz', 'genre' ) ) {
// do something
}
You can use taxonomy to deal with such problem. Use taxonomy to filter contents according to your requirements. Use register_taxonomy() to register a taxonomy for CPT.

Woocommerce product form fields

I would like my product page that customers fill 5 text fields and choose 1 field type radio.
So my product page is a form where customers ask a question, fill some information and choose a paid option.
Like this french page => http://www.avocat-bervard.com/paiement-honoraires-consultation-juridique/
Is it possible with Woocommerce ?
If so, can you explain me how ?
Thanks.
You can create nice forms with plugin Ninja Forms :). Its a very cool plugin, with a couple of settings: sending emails, when submitting forms, etc.
It is also supports shortcodes, with this method you can implement your form on every single product page, or even display it in a widget area.
For widget area:
You need to enable shortcodes first in functions.php
add_filter('widget_text', 'do_shortcode');
Then call the shortcode in Appearence - Widgets
For template:
You need to edit the file where you want this form to display, single-product.php, meta.php :) etc.
To insert shortcode in template file you need to use the below code:
<?php echo do_shortcode( $content ) ?>

Dropdown of existing posts in a metabox

I want to have ability to choose for each page what post should appear in a sidebar, from multiple posts type. So I understand that I need a meta box with a dropdown list of all posts, but I don't know how to build this in functions.
I only found this solution which is quite similar to what I want, but this doesn't help me to much, because I can only choose from a single post type and display only in post pages.
There is a free plugin that will solve all of your woes. It's called ACF or Advanced Custom Fields. It has the ability to add a list of posts to a field and attach that field to pages. Here's how you'd do it:
First install the plugin and navigate to the custom fields screen. Setup your field exactly like this:
Then in the options below that section you need to select these options:
That will tell ACF to put the field only on pages. After you have set that up you will get a little sidebar block like this:
You can then select each post for the page and it will return that object on the frontend. You do need to use a little code to get the frontend to spit out the posts you need. Here is the code to get a frontend option from ACF. Inside of the sidebar.php file you need to add this code:
global $post; // Get the global post object
$sidebar_posts = get_field('posts', $post->ID); // Get the field using the post ID
foreach($sidebar_posts as $sidebar_post){ // Loop through posts
echo $sidebar_post->post_title; // Echo the post title
}
This will simply loop through the posts you select and echo out the title. You can do more with this by adding some other Wordpress post functions using setup_postdata(). This will allow you to do things like the_title() and the_content().
Hope this helps!

How do I use different category template in wordpress?

I am using Twenty twelve theme in wordpress to make a project. To display various styles of pages I can choose custom page template page, but I have to use category instead of pages.
But how I make different category template and use them ? Thanks.
You can do it in almost exactly the same way as you would do with pages.
Just follow the Wordpress Template Hierarchy:
"category-slug.php"
"category-ID.php"
etc
http://codex.wordpress.org/Category_Templates
So, if you have a category with the name "cars", the name of template for that category should be "category-cars.php" :)
Edit: a few minutes too late :(
You can check category by id and use native function where it needed.
get_template_part( 'custom_category', 'category' );
Also You can try something from here Wordpress Codex

Resources