How to add fictional category wordpress - wordpress

I'm trying to do something, on wordpress which i'm not sure is possible.
So basically, I'm using Magic fields for two things. I've created a panel called "Member", and another one called "Member actuality". I've created two categories, member and member actuality which I've binded too magic fields post.
When I go on category (site.com/category/member) member I have the list of all my members.
When I click on one of my members (site.com/memberName) I have the description of the member. So for the moment everything is ok.
Now what I want to do is find a way too display actuality of one member. Maybe something like : (site.com/actuality/member) But I have no clue on how to do that. So if someone can help me.
I'm not sure i've explained it right, so please if you didn't understand ask me to reformulate.
Thanks for your future help

I found a way to do go throu this.
I've first created a new tag when a post was added, and that allowed me to use the tag directory which i didn't used before !
!

Related

How to choose the last member of an array in a datalayer?

Then I would like to get the smallest child Category of a post that belongs lots of categories (via the datalayer pageCategory used plugin called GTM4WP by Duracell Tomi).
How can I do that?
I had already known to get the biggest category: pageCategory.1
Already tried pageCategory.10 or pageCategory.length-1 but didn't work. I'm not really familiar with Javascript. Please guide me
You need to use the length of the array, but with a different syntax:
pageCategory[pageCategory.length-1]

User access to CPT (Custom Post Type) without access to regular posts

I have created a custom post type that for the sake of this question we can call "my_cpt".
I have also created a new role which we can call "my_role".
What I want to do is give "my_role" access to "my_cpt" without adding the "edit_posts" capability because that gives access to other post types which I do not want the role to have access to.
I have tried variations of numerous bits of code I have found but none have worked so I don't really know where to begin. Based on that I don't have any base code to display here.
A plugin like this one should enable you to do this: https://www.role-editor.com/
Ended up being easier than I thought.
I created a couple capabilities... "read_my_cpt" and "edit_my_cpt".
The "my_role" has permissions to both the capabilities.
I then just had to change the capability_type for the CPT to "my_cpt" instead of "post"

How to check that the a page uses a taxonomy in WordPress?

I need to edit a template's header.php file and I want to check if it has a taxonomy named "store". If so, then I need to extract it's tag_ID.
When I edit the page (it's not a WordPress Page type) I can see these values in the admin url:
taxonomy=store&tag_ID=720
So I know there is a way but I'm having trouble getting any good results. I tried the
method detailed here to extract at least the tag_ID but I'm getting NULL:
$tag_id=get_query_var('tag_ID');
echo $tag_id; //NULL
Edit:
To be clear in regards to the tag_ID because it may be confusing, all I really want is to get the unique id of the requested page so I figure seeing first if it has a taxonomy named "store" and then getting the right one using the tag_id.
AS far as i understand your question, You should try this:-
$data = get_queried_object();
With this, you can get what page/post/taxonomy is being called.
Just print-out/var_dump this $data variable, you will get full object of page/post/taxonomy.
Hope this may help you.

Checboxes input helper PodsCms

i created a multiple checkboxes input helper adapting the code from this http://podscms.org/packages/checkboxradiobutton-yourvalues/
I modified it so that people don't have to hardcode values into the helper; instead values are taken from the column comment field (having a data field for columns would be appreciated in pods 2.0!)
Here is the helper: http://pastebin.com/w0UxDmnG
I encountered two problems, the first of which i already solved:
At thw beginning i enclosed the whole code in a function, to keep clean the namespace (isn'i it the right thing to do?). but i noticed that i do this, when i have two columns with this helper many strange things happen: the second column is blank, doesn't show checkboxes. After the second column with this helper no more columns are shown.Rich editor commands on all textareas don't appear and textareas themselves are non editable.
I suppose is an effect wrapping the code in a function. Unwrapped the code, problems are gone! (i wrote this because it can be helpful to developers out there.
I wanted to add a "Other" text field for comments outside the choices displayed with checboxes (like in google forms, for example). To trigger this "other" ("Altro" in the package i shared), pod creators have to write [] in the comments (eg: foo, bar, cat, []).
I was able to make the input, but, once data is filled in and the pods is saved, the data in the text field get lost. I really have no idea on how to fix this!
I hope my experience, and this helper could help someone, and i hope some could help me to improve it!
(and please someone create a podscms tag!!)
Pods 2.0 solves this kind of issue, it's now built into core as a field type option. Enjoy!

How to find which menu a node belongs to in drupal

I currently have nodes setup on my site, and each node belongs to a particular menu (not primary or secondary prebuilt menues).
How can i find out which menu a node belongs to?
Maybe this is what you mean:
$trail = menu_get_active_trail();
$lastInTrail = end($trail);
$menu_name = $lastInTrail['menu_name'];
menu_get_active_trail() returns a breadcrumbs like array, the last breadcrumb represents the current node.
Cheers,
Laurens Meurs, Rotterdam
I'm a noob, so don't bash me if what I'm going to write is worthless babbling.
I think you can't do that directly, unless there's some smart module out there that would do all the nasty SQL queries necessary to check this.
Node info is stored in the SQL table "node", and is identified merely by NID (node ID, which is the node number that appears after /?q=node/ in the address). Their aliases, if any, are stored in "url_alias" table, where you can find columns "src" and "dst", identifying the original and the aliased path (for instance, src='node/123', dst='my/url/alias'). The menu links can be found in the table "menu_links", where you can find the columns "menu_name" (the machine-radable name of a menu) and "link_path" (either the node/... or the alias).
So, what you'd need to do is the following:
get the current node's NID
query "url_alias" if there's an alias for node/NID and retrieve it, otherwise leave node/NID
query the "menu_links" table for the path you've determined and retrieve "none" or the menu's machine-readable name
You could then also query the table "menu_custom" to check what's the human-readable name of the menu you've determined.
Anyway, that's a complicated query (several queries?) and I'm a MySQL ignorant, so I can't help you with the actual code you'll need to use to check all that :P.
This isn't a direct solution and I see from your reply to a previous answer that you didn't wanted the simplest solution possible, but I thought I'd mention this option. The Menu Node API module maintains a table which Drupal lacks, a node-menu relationship table.
The module does nothing on its own, but there seems to be contributed modules which build on this, so depending on how complex your problem is it might be a starting point.
http://drupal.org/node/584984
Updated: Sorry guys, didn't even realize I had posted this link. I think I intended it as a draft and simply posted it when closing tabs. That said, mingos (above) is right on.
My link is to a function menu_get_active_menu_name() that appears to provide you with an array containing the active menu for the current page. As I presume that is what you are using it for, it would be a nice way to abstract yourself away from the database calls that might cause problems down the line.
I myself have never tried it, which is probably why I didn't elaborate and post. well... at least didn't post on purpose.

Resources