Advanced Custom Fields – Custom Search
-
This may be a simple question, but I am trying to create a shortcode that will create a link to a list of posts with a specific field defined in the Advanced Custom Fields plugin. Let’s see if I can explain this well…
The blog has existing content and some of the posts have ACF defining options such as location, category, and price range. I will be using shortcode like this:
[add_category category="photographers"]I need my function to create a shortcut to a list of pots wth “photographers” defined in ACF. I simply don’t know what that link would look like, so I have no clue where to go from here :/
Here is my my function so far. :
function add_category_function( $atts ) { $cat = $atts['category']; $slideshow_output = ''; $slideshow_output.= '<div class="vendor_category_block"><div class="vendor_category_photo"></div><div class="vendor_category_title"><a href="' . the_field($cat) . '">' . $cat . '</a></div></div>'; return $slideshow_output; } add_shortcode('add_category', 'add_category_function');Currently the links creates the url of the page the shortcode is inserted on.
The topic ‘Advanced Custom Fields – Custom Search’ is closed to new replies.