How to insert a custom post field in a Wordpress Pod? - wordpress

I recently started using the Wordpress Pods plugin and I'm trying to insert a custom post field in the Pod.
It is not working. Is there any way to do this?
I have created a pod named "network-section"
This pods works:
[pods name="network-section" where="id = '4'"]
[/pods]
However, I want to use the {#network} field because I have a lot of posts with different network categories.
This is not working:
[pods name="network-section" where="id = {#network}"]
[/pods]
{#network}"] is a custom post field.
Thanks!

your shortcode won't work like that I'm afraid. The ID field is looking for an integer that corresponds to the unique ID of a certain post. That's why your first example works but second one doesn't.
If you want to have a sub-selection of network-section posts, you should find a different way to select them instead of using 'ID" ,(which, by definition, will pull at max only one post).
For instance, you could add a custom taxonomy and use that to filter by in the shortcode, or sooner other field.
The easiest solution might be too create a field in your Post called "network category" then door each of your posts you can give them a particular number.
That way, in your shortcode, you can do:
[pods name="network-section" where="network-category.meta_value = '2'"][/pods]
N.B. you will probably need to use that ".meta_value" to get the right bake in your shortcode, but it depends on how you sweet it up. AND you'll need also need to add your html and other code somewhere (can be in a Pods template or even between shortcode open and close tags) otherwise there will be nothing to display...
Good luck!

Related

Pods Framework List Items Widget

I'm building a Wordpress site using Pods and Elementor. My posts have a Pod text field called 'year'. I'm trying to use the Where parameter in the Pods-List Items widget to filter the posts by 'year.' But I can't seem to get the syntax correct. year='2020' doesn't work and the same with many other attempts. Please help and thanks in advance.
Pods can be filtered by means of a shortcode. The list-items widget is just a tool that helps you easily make such a shortcode.
To add the year filter, you'd do something like this:
By shortcode directly
[pods name="my_pod_name"
where="year.meta_value = '2021'" template="template_name_if_using_one"]
In the Pods widget
In the "where" field, you'd just write:
year.meta_value = 'value_to_filter'
The important bit, and which people frequently forget, is adding the .meta_value to the the field name they're filtering on.

Wordpress: get previous_post_link() based on custom field value

I have a custom post type. Pages of this custom post type are displayed via a special template. in this template i use previous_post_link() and next_post_link() to create links to previous/next posts of this custom post type.
Since I currently only want to show a few of these custom-post-type pages to my users, I created a custom field called release with a boolean true/false value to indicate if these posts should be shown.
Obviously, the previous/next_post_link() functions should also be aware of that. However, they are not currently. That means they also link to pages where the custom field released is set to false. How can I tell these functions to only use pages where a custom field (released) has a specific value (true).
Update: I know that the solution is to apply some filters to the default functions and to somehow adapt the SQL query which is used to retrieve previous/next posts. However I do not know how to put together the puzzle pieces (where/how to apply the filters and how to adapt the SQL)
This may be related to this question, however I dont really know what to do: https://wordpress.stackexchange.com/questions/8823/how-to-order-adjacent-posts-prev-next-by-custom-field-value
This seems also to be related: https://wordpress.stackexchange.com/questions/96670/custom-post-type-navigation-on-custom-field
couldn't get it to work even though I know how it SHOULD work: addFilter() for get_{$adjacent}_post_join and get_{$adjacent}_post_where with custom SQL query code..
However, this plugin did the trick for me: http://www.ambrosite.com/plugins/next-previous-post-link-plus-for-wordpress
I used the in_same_meta key.

Wordpress Add actions and filters only if certain condition met

I am customizing wordpress comments to add multiple custom fields. So i have added filters and actions to show fields, validate them, process them and finally show them in comments. I have written these and they are working fine.
However i only need them only for Post which belongs to specific category and comment is not a reply of any other comment.
I tried few things but nothing seems to work. Can somebody provide me a working solution.
Just to start, I think you could put conditions inside filters and not filters inside conditions. That said, for posts in category and category archives you can use the 'conditional tags' is category (for archive) and in_category (for posts):
https://codex.wordpress.org/Function_Reference/is_category
https://codex.wordpress.org/Function_Reference/in_category

WordPress Custom Post Logic

I'm a newbie here, but I've been trying to understand and research this for the past couple of days to no avail.
I created a custom post type (video) with a taxonomy associated with it (industries). The taxonomy "industries" has multiple categories (I'm not sure if in this case they are called terms rather than categories; correct me if I'm wrong!) such as IT, Construction, etc. For arguments sake, let's say under the category IT there is a single post named Web Developer.
First question: With the logic above, how would I manage to reach the single post (web developer) with the URL: .../video/IT/web developer?
Second question: If on the video page I would like to display all posts in all categories, what template page should I create? Is it archive-video.php? The same question goes for the category (IT in this case): Which template page should I create in order to display all posts under a specific category?
I'll answer your second question first:
Yes, the template you should use for displaying all the custom post types would be the CPT archive, so archive-video.php sounds right.
For the categories (the exact way to say it would be "taxonomy terms" indeed), you would use taxonomy-{taxonomy}.php or even taxonomy-{taxonomy}-{term}.php if you need to get more specific.
About your first question, there is currently no core functionality to use custom taxonomies in your permalinks, but this might help you.

Wordpress, alternative single post template

For a project of mine I need to define an alternative template for single posts.
To be more specific I need each post to be displayed as usual when the website is browsed but I need to create different single pages reachable from different URL to create a sort of a mini-website for each post.
(I'm actually using the WooCommerce plugin and what I need to do is to create a mini-website for each product. This needs to be something "outside" from the main website, with a complete different graphic template and is going to be reachable through a QR-code).
Hope it makes a bit of sense.
Thanks for your advices and/or suggestions.
Angelo
I think the easiest way to do that is by registering a custom post type for the special posts that get this special "single.php" template. Then, you can simply write a new single template titled post-[custom post_type].php. Any post you register of this type will use that template.
OR...
If you don't actually need them to be posts, it's even easier if you publish them as pages. By default, pages let you assign a specific page template in the edit screen. So you could make any number of custom templates. Just make sure you add the special header:
/* Template Name: Custom Page */
...so WP knows it's a page template.

Resources