WordPress List Posts with Custom Field Plugin

This plugin provides a shortcode that displays a list of posts with a certain custom field. Since you can supply multiple custom fields you’re able to aggregate posts with different custom fields. Furthermore you can easily change the sort order.

You can download the plugin here.

Howto

Once you’ve installed the plugin you can use the shortcode list-posts (or lp for short) to display posts. Say, if you wanted to get all posts with the custom field howto you would enter this into the content of a post/page:

[lp field=howto]

This results in a list of posts with the given custom field.

Attributes

You can use the following attributes in the shortcode.

field
You can supply the custom field here. If you’d like to use multiple custom fields just separate them with a comma.
orderby
By default the posts will be ordered by their publication date. If you’d like to order them by their title you would use post_title. Look at the fields of the wp_posts table and pick whatever you like. Ordering by the value of a custom field is possible too: just use cfvalue:field here and replace field with the real key of the custom field that should be used during the sorting algorithm.
order
Either use ASC or DESC for ascending or descending order respectively.
titlefield
The plugin uses the standard title of a post to display the title but may use a custom field instead. This comes in handy if you want to display another title for a post in the list generated by this plugin without chaning the post’s original title.
excerptfield
Again, this field lets you choose a custom field which will be used instead of the post’s excerpt. Say, you’re using the All in one SEO plugin which stores the meta description in a custom field called description you may use its value instead of the standard excerpt.
titleprefix, titlesuffix
The title that’s displayed can have a custom prefix or suffix. The constant %PERMALINK% will be replaced with the permalink of the current post or page.
excerptprefix, excerptsuffix
You can specify a custom prefix or suffix for the excerpt as well.
split
In case you specified a custom field via the attribute field that may be attached multiple times to a single post or page you can split the results by turning on this attribute, e.g. with split=1. This way the output may contain a post or a page several times.
category
You can make sure that the results will be associated with the given categories. Just supply a comma separated list of category IDs.
having
This attribute helps you displaying posts that have a given custom field set to a specific value. It’s a great way to display all posts having a certain custom field and another one with a particular value. Say, you only want to display posts having a field blah with its value set to 123 you would use having=blah,123 in the shortcode; see that by default a comma is used to separate the value from the field’s name, multiple fields are separated with a semicolon.
having_delim and having_delim2
In case your custom field contains the default delimiter that is either used to separate the key from the value or multiple custom fields from each other in the having clause you can change the delimiters. This would be an example to get all the posts having a field test set to either xxx or xxx,yyy: [lp field=test having="test;xxx|test;xxx,yyy" having_delim=";" having_delim2="|"]. Due to the fact that the value xxx,yyy contains the standard delimiter “,” I used a “;” instead.
Defaults are as follows: having_delim = “,” and having_delim2 = “|”.
having_conj
You can switch between and or or as the conjunction of multiple fields in the having clause; default is or. This way either all or just at least one field with it’s key / value combination needs to be present to add the post to the result set.
limit
Helps you to limit the amount of displayed elements. If you’ve got five posts with a particular custom field but only want to show the first three you’d use limit=3.

Examples

I’ve created separate pages for all my WordPress plugins. All of them have a custom field called wordpress. The following shortcode was used to produce the list as you can see it here:

[lp field=wordpress orderby="post_title" order="desc"]

If I create a new page for a plugin I just have to annotate it with wordpress and the list will display it automatically. Neat, isn’t it?

86 thoughts on “WordPress List Posts with Custom Field Plugin”

  1. Just found your plugin and I would like to use it to list my article sorted by author. Rigth now I am getting a list of all articles. How can I have a headline of the author and beneath the articles that belongs to them.

    My custom field is author and I use it to store the author of the article.

    Thomas

  2. Hi Thomas,
    the plugin doesn’t support this because it had to look at the content of the custom field and compare it to some pre-defined value. Of course, you could adapt to plugin to do this but I think you’re better off using the function wp_list_pages along with the parameter authors.

  3. hi christian,

    ich wollte dein plugin installieren, um gewisse beiträge auf einer statischen seite anzuzeigen und eventuell mit einer anderen überschrift zu versehen.

    leider war ich nicht erfolgreich. ich habe dem gewünschten beitrag ein benutzerdefiniertes feld hinzugefügt (schlüssel=field, wert=rezept). auf meiner statischen seite im editor [lp field=rezept orderby="post_title" order="desc"] eingegeben, aber leider ohne erfolg.

    ich bin nicht besonders versiert, also vielleicht mache ich wo einen fehler. hast du ihn entdeckt?

    im prinzip würde ich genauso, wie du auf deiner pluginsseite eine bebschriebene liste erstellen wollen. hoffentlich klappt es mal.

    danke dir und grüsse

    horst

  4. hi christian,

    bin schon eine spur weiter: der wert schlüssel muss den field wert enthalten (also z.b rezept).

    wie kann ich aber die beiden felder excerptfield und titlefield anzeigen und auslesen lassen?

    danke und grüsse horst

  5. It is possibile order the list by a value of a custom field?
    now I can order by post_title (i.e.) but I would order by a value of a particular custom field too.
    tnx

  6. Is it possible to modify this to only list posts with a specific custom field.

    ie; the plugin will look for all posts with a custom field of Blah.

    I want it to list only posts where Blah = 123 (for example)

    Is that possible? I assume it’s just a modification to the code, but I can’t figure out where.

  7. Hi Mike,
    search for the first foreach in the plugin’s file. Inside this loop you’ll have to add code like the following:

    $blah = get_post_meta($post->ID, 'Blah', true);
    if ($blah != '123') continue;

    This should make sure that only posts having a custom field “Blah” set to “123” will be displayed.

    Update: This can be done with the having attribute now.

  8. Wow this sounds great. I’ve been battling to print a set of posts, with a specific custom field value, but need to post them inside of another post. Is there any way of using this plugin with a template tag instead of shortcode though?

    I’ve just tried using the plugin and it basically adds all custom fields from the specific field not just the ones with the value I specified.

  9. I’ve been using the plugin with a placement like this:

    [list-posts field=xyz having=xyz,none]

    When I upgraded to WordPress 2.9.1 from 2.8.x, the page changed to a list of “Array” strings. Instead of the post title, the string “Array” would be there.

  10. FYI, I was able to patch it for my purposes by commenting out the following section in the plugin:

    # set correct title/excerpt
    #for ($i = 0, $n = count($result); $i title = lpcf_get_custom_field($post->ID, $titlefields, $post->title);
    # $result[$i]->excerpt = lpcf_get_custom_field($post->ID, $excerptfields, $post->excerpt);
    #}

  11. Very nice, simple plugin.

    2 questions:

    1. In many posts, I have the same custom field key with different values. Your plugin seems to recognize this, but only lists the value in the first instance of the key. Is there a way to solve this?

    2. I think that this has been mentioned before, but is it possible to sort by the value of the custom field?

    Thanks,

    Adam

  12. Hello,

    Is it possible to combine this plugin with a WP category shortcode?

    If I have a number of posts about different airlines in the category ‘airlines’, with a custom field holding the airline name. To write a post that includes a list of these articles I need to combine the shortcode for list-posts and a shortcode for the category.
    John

  13. Hi John,
    I may include another attribute category that would allow you to use those posts only that are part of the given category. This would do the trick for you, I think.
    Update: version 1.8 of the plugin contains this feature.

  14. Hi David,
    unfortunately I haven’t documented this but here’s how you’d do it. Add the following to the shortcode:

    titleprefix="<h3><a href='%PERMALINK%'>" titlesuffix="</a></h3>"

    The special string %PERMALINK% will be replaced with the corresponding permalink.

  15. Hello,
    Nice plugin.

    Is it possible to filter a list having X AND Y values from more than one custom fields?

    For example, show movies where director is Woody Allen and format is blu-ray.

  16. Hi Jos,
    the most recent version of the plugin (1.9) now has this feature and you can add as many key-value pairs separated with a semicolon; the key is still separated from the value with a comma.

  17. Hi,

    This plugin is exactly what I’ve been looking for! I just have one question. Is it possible to have the list display the “featured image” above the post title? Not sure if that makes sense. I just want people to see a thumbnail of the post along with the post title.

  18. Hi Nicole,
    since the plugin doesn’t provide an output that’s suitable for everybody you’ll have to adapt the part that displays the content as you see fit. If you know some PHP, HTML and the WordPress API that shouldn’t be a problem. You can contact me for professional help as well.

  19. Hi Christian,

    The BEST Plugin ever…
    Question: I want a user to enter a value through a box in sidebar (which will be the field value) and based on this to click a submit button to show the list page…

    Is it possible?

  20. Hi Alexandros,
    sure but you need some logic to extract the value the user entered and hand it over to this plugin. You’ll need some PHP for this and this can be as easy as the following code:

    echo lpcf_shortcode(array('field' => $_POST['user_field']));

    Given that the name of the input field in your sidebar is named user_field the above would display the list of posts with the given custom field; I haven’t tested this though.
    Please be careful with this approach because the plugin doesn’t check against any SQL injection attacks. You should think about validating your user’s input before handing it over to the plugin’s main function. By default, the plugin doesn’t check the user’s input due to the fact that the input entered via a shortcode should come from a trusted source in the first place.

  21. THX Christian For the plugin
    Work out of the box…

    I cannot found solution when some of custom fied are set by the user. some are not filled

    Sur you have a solution for that…!

  22. I have a blog with over 30,000 posts and this plugin seems to stall…anyway I can make it work with a blog of this size?

    Thank You. Great plugin!

  23. Hi Jeff,
    you should make sure that the number of posts with a certain custom field that you’re selecting – with the field attribute – isn’t too large; I guess a few thousand posts should work though. Furthermore you can use the limit attribute: this way only that many posts defined via this attribute will be returned.
    If all that doesn’t work maybe you should drop the plugin and check whether you can archive the same functionality with the query_posts function. It allows you to select posts based on their custom fields too; meta_key, meta_value or meta_compare come to mind. This function call before the loop and a properly configured pagination may help you as well.

  24. Hello Christian.
    Does your plugin work on WordPress version 3? I’ve just tried it and I don’t see the posts I expect.
    Thanks,
    Greg.

  25. Hi Greg and Mario,
    I’ve tested the plugin with the most recent version of WordPress (3.2.1) and everything seems to be working fine. If you’ve got a specific issue with the plugin on your installation please contact me via the contact form and let’s find a solution.

  26. hallo christian,

    wieder muss ich mich herzlich bedanken für das tolle plugin. eine frage habe noch zum excerpt/excerptfield: besteht die möglichkeit die normale excerptfunktion von wp zu verwenden/implemenrieren? (the_excerpt) – ich habe versucht ein bisschen am code zu basteln, bin aber gescheitert 🙁

    wenn ich dich richtig verstehe, müsste man zuerst ein excerptfield bestimmen oder erstellen und füllen, erst dann wird ein excerpt angezeigt.

    vielleicht wäre es ja nicht nur für mich toll, wenn in einer zukünftigen version des plugins die option besteht, auch das normale wp excerpt anzuzeigen…

    herzliche grüsse

    tigerkater, für jede hilfe dankbar!

  27. Hallo tigerkater,
    es ist eigentlich viel einfacher: die Angabe von excerptfield weglassen und das Standard-Exzerpt wird genutzt; Tabelle wp_posts, Spalte post_excerpt. Natürlich kann man dies auch im Code hartkodieren, dann aber bitte get_the_excerpt nutzen.
    Ein Mischbetrieb zwischen einem Exzerpt in einem benutzerdefinierten Feld im einen Post und dem Standardexzerpt im anderen Post ist aktuell tatsächlich nicht möglich.

  28. Can we have thumbnails on the post lists? I found this plug-in very interesting, but I don’t see how we can have thumbnails showing. Please let me know if I am doing something wrong.

  29. Hello Coolpix,
    by default the plugin doesn’t have a feature that allows you to show thumbnails in front of each result. In case you know PHP please adapt the output of the plugin to include the desired images which should be pretty straight forward. If you would like to contribute this change to the original plugin simply get in touch with me.

  30. Hi there,
    Can you please write an example of a full line of code showing the “having” function being used? I keep getting “No custom field found. Add it to the shortcode. ”

    Thank you!

  31. Hi Nathan,
    this message says that you should add a custom field to the shortcode like so:

    [lp field=test having=blah,123]

    This would retrieve all posts with the field test having another field called blah which is set to the value 123.

  32. The standard way that WP works – showing items in the order that they were posted to the system – meant that they were displayed in the wrong order on a page of events which I wanted listed in the order that the events would occur. Editing the posted date – which was a solution suggested by some – did not change the display order.

    To overcome this problem, I added a custom field for the dates of events. Your plugin now tests if the field is used and, if it is, creates the correct output showing a list of upcoming events in the date order as entered in the custom field.

    Once the event is over and I do not want to display it any longer, I delete the data in the custom field. Unfortunately, the plugin still shows the entry even though the field is now blank.

    Is there a way to test the value of the data in the custom field and only display posts where the tested value meets certain criteria? For example, only show items that have a date after today’s date?

  33. Thanks for this useful plug-in. For the most part it works great, but when I try to give a post more than one custom field so it appears in more than one section, I can’t get it displaying correctly, even when using split=1.

    For example, the following does *not* display a post in both sections – it actually suppresses display of all posts. Let’s say a post has the custom field “overview” with the value of “another-theme” *and* “great-work” and I want the post to appear in both of the lists:

    [lp field=overview orderby="post_title" having=overview,another-theme split=1]

    [lp field=overview orderby="post_title" having=overview,great-work split=1]

    Is this the correct implementation? Removing split=1 causes the posts to be displayed correctly, except that a post in multiple sections is only displayed in a single section, not both.

    Any assistance appreciated. Thanks in advance.

  34. Hi Phillip, Kathryn and Usama,
    @Phillip: the behavior you’re describing seems to be really anoying although I couldn’t reproduce it on my end. Answering your question: sure it would be possible to add a certain method that would allow us to compare a custom field and some other value and maybe I can add this in a future version.

    @Kathryn: this was in fact a bug in the plugin and version 1.9.1 should fix this. The split attribute is used in another context, simply leave it out and the above code should be working for you just as expected.

    @Usama: you can use orderby and order to alter the order of the posts.

  35. Hi,

    I’ve been using this plugin and seems like its very nice to adapt. I have 1 problem in terms of using having.

    If I only use having it will be error:
    No custom field found. Add it to the shortcode.

    [lp having=cp_state,"Kuala Lumpur" orderby="post_title" order="desc"]

    But if I use:
    [lp field=cp_city having=cp_state,"Kuala Lumpur" orderby="post_title" order="desc"]

    It will show me all the post with field cp_state but not only Kuala Lumpur.

    What I need is, I need to create pages for every state in the country, and I would like to list all the post that related from the state based on the custom field cp_state.

    How to do that ?

  36. Hi Raffaell,
    according to the current implementation you have to add the field attribute; it’s mandatory. Basically, this can be any field that’s common to all the posts you’d like to select.
    Regarding the having field everything looks okay with your setup and it should work as expected. The only thing you might want to change is to put the double quotes around the whole value of a certain attribute, i.e. not only “Kuala Lumpur” as in your example.

  37. Christian,
    Thanks so much for this. It was _exactly_ what I needed for my index pages for our website, even down to the “split” option.
    One suggestion: It would be nice to have the list with headings with titles indented like
    Allen
    #66, “Essential” (01 22 12)
    Phelps
    #68, “Uncommon” (02 05 12)
    #62, “Hope for the Holidays” (12 25 11)
    Thanks again for all the work that obviously went into creating this.

  38. Hi Russ,
    first off, thank you for the great feedback. I know that the default output might not be exactly what you’re looking for. Instead of adapting the plugin to all different kinds of output here’s how I do it. I use the plugin on several websites as well, install it and tweak it’s output just the way I see fit for the particular project. Simply do this as well, it’s pretty easy and still leverage the work that already went into this plugin. For me it’s a quick way to get going and adapting the output should be the only thing that you might want to change.

  39. Hi,

    I like the plugin stable operation and simplicity, very good work! Although I need something similar so I’m hoping somebody will help me out here…

    I need to automatically generate pages with shortcodes included… cron or publish detection, anywho the parameters should be:

    Page name = custom field value
    Shortcode = [lp field=custom field value]

    Then I would search only within pages and result page should show pages as groups of posts with thumbnail in front… Actually it would be grouping posts by custom field tool…

    This could be a great feature of the plugin, but if anybody can tell me how to do it my self, I would appreciate it… thanks!

  40. Update:
    I found this plugin “default post content” which allows you to enter some text in custom field and then it shows this text on every post by default, so I wonder if it could be hacked to do that with pages and with a combination of both plugins it might be possible to achieve this, right?..
    Or is it better to just get some developer to write me a complete plugin?

  41. Hi Mihail,
    generally speaking, you should try completing what you’re trying to do with existing plugins first before implementing a new one; it’s much more cost effective in the long run.
    This plugin isn’t limited to selecting posts by certain custom fields but can do the same for pages as well, it doesn’t matter. That said, you can add your custom field to pages as well, use the shortcode, fill out the field attribute accordingly and end up with a list of all the pages that use this custom field. If you want to show the page’s thumbnails in front of the content you should simply adapt the output of this plugin to suit your needs.
    Another hint is checking out WP_Query before implementing something new or maybe even using this plugin. It’s pretty powerful and you can select posts and pages via a variety of options.
    I guess there’s a seventy percent chance that WP_Query does the trick for you. The remaining twenty percent are covered by this plugin and in ten percent of all occasions you may need to implement something new.

  42. Hi Christian,

    Thank you for your quick response…
    It maybe sounded like complicated think, but I see it very simple:

    Pages should represent groups of posts with the same custom field…
    Pages should be generated automatically based on the specific custom field of all posts.
    Pages should be named by that field.
    Those pages

    It’s more for the listing those groups in the results page, an when the group/page is clicked then it shows all the posts within the group…
    I manged to list all posts with the same custom field, but the list is too big and not what I need…

    Will give it a try with WP_Query anyway, but I doubt it can list as groups of posts…

    Cheers!

  43. There are hundreds of posts coming in all the time so this need to be done automatically…

    I’m pretty sure, It is possible to achieve this with your plugin, just with some generator addon…
    thanks

  44. Hi Mihail,
    now I understand that you want to generate the pages automatically containing the corresponding shortcode configuration with the custom field. Even though this is programmatically possible, i.e. creating pages/posts in code is a pretty straight forward thing, I don’t know whether this might be the right solution for you.
    Instead I guess you’re way better off using categories or tags for this matter. This way you’ve already got the archive pages, can use a clean URL scheme and all the posts are grouped together just nicely. Have you thought about this solution yet? Why didn’t you chose this existing feature?

  45. I have your plugin implemented and everything works as expected except that I am having a problem with the limit parameter. The situation is like this. I call your shortcode twice on a page to display 2 lists of posts that meet my criteria. The first one has a limit of 5 and the second one is set to 100. The first instance of the shortcode limits to one post and the second one lists all 100. Have you ever see thissituation before and if so, is there a solution? Thanks in advance!

  46. Hi, your plugin is great, and unique of course. However, I am having difficulties with the attribute “having”. [lp field=pulisher having=publisher,sheba][lp field=pulisher having=publisher,sheba prokashoni]
    While the 1st one works, the 2nd is NOT. The difference is the ‘space’ in the value. So, I have tried putting single and double quotes around, but it doesn’t work either way. Can you explain it? And, is there any workaround?

  47. Dear Prativasic,
    your second option works – I just tested it here – if you adjust the having attribute like so:

    [lp ... having="publisher,sheba prokashoni"]

    The double quotes have to wrap the whole value of the attribute. This isn’t special to my plugin but applies to all shortcodes in WordPress if the value should contain a white space.

  48. Pingback: Angis Blog » Blogbastelei: Neue Plugins und Seiten

  49. Hallo Christian,
    ich habe das Plugin ausprobiert und finde es wirklich hilfreich. Allerdings habe ich eine Frage zum having-Parameter: Kann ich damit auch ein Select-Field abfragen? Wenn ja, wie?

    Ich habe noch ein Problem: ich habe das Feld so eingetragen: [lp field=id orderby="post_title" order=ASC] Trotzdem werden die Posts nicht korrekt sortiert, was wohl daran liegt, dass ich bei einem Artikel den Post-Titel verändert habe. Wird nicht der aktuelle Post-Titel eingelesen?
    Vielen Dank, Gruß,
    Krissie

  50. Hi Krissie,
    soweit ich weiß, können die Custom Fields in WordPress nur Text enthalten – was meinst Du also mit einem “Select-Field”? Gibt es diesbezüglich vielleicht ein neues Feature, das ich nicht kenne? Bezüglich der Sortierung nach dem Beitragstitel liest der Plugin immer den aktuellen Titel aus und sortiert basierend darauf. Sollte die Sortierung “falsch herum” sein, hilft der Parameter order mit dessen Hilfe die aufsteigende- (ASC) oder absteigende (DESC) Sortierung festgelegt werden kann.

  51. Hallo,
    gibt es eine Möglichkeit, excerptfield nicht mit auszugeben? Ich benötige nur eine Liste mit den Links, ohne Excerpt. Als workaround gebe ich excerptfield=statt_excerpt ein und lasse statt_excerpt frei – das ist etwas umständlich.

    Ansonsten ist es genau das plugin, was ich gesucht habe, vielen Dank dafür!

  52. Hallo Albrecht,
    in diesem Fall sollte eben die Ausgabe des Plugins angepasst werden. Bisher ist dies noch nicht über eine leicht zugängliche Konfiguration möglich, aber die Anpassung ist denkbar einfach. Dazu die Plugin-Datei öffnen, ab Zeile 190 ff. beginnt die Ausgabe. Hier könnte statt einer Description-List (dl) auch etwas anderes gewählt werden, wie bspw. eine Unsorted-List (ul) oder etwas gänzlich anderes. Soll nur eben das Exzerpt nicht mit ausgegeben werden, die Zeile 219 in "<dd></dd>\n"; ändern.

  53. Great Plugin Christian.

    Is there an ‘easy’ way to adjust the output of the list?

    Currently I getting a very plain list of the post titles. I’m trying to have the list output additional fields than just the title and possibly adjust the CSS of the list. If not easy could you direct me to the place to edit?

    Thanks.

  54. Hi Rob,
    right now there’s isn’t a way to configure the output but simply open the plugin’s file in an editor and scroll down to lines 190 and following. You’ll see that the description list (dl) is created there, on lines 218 and 219 the term and description is added to the output and line 223 closes the description list again. You can, e.g., remove the description list and replace it with whatever you need and even add more information by using the available variables, for example $post.

  55. Amazing Plugin Christian, very useful! Need you help, with a problem. My custom field name is “services”, the user has the option to select 1 or more predefined “service_values” [from a list of 25 services] while creating a post.

    I would like to show posts with a particular service selected, i tired using [lp field=services having="services,dentalimplants" orderby="post_title" order="asc" ] but it dose not work for me. When i use [lp field=services orderby="post_title" order="asc" ] it works but i am not able to filter results based on the key vakue. Could you please help, Thanks!

    Cheers,
    Kaustubh

  56. Hi Kaustubh,
    I created two pages, both having a custom field named “services” with the value set to “dentalimplants”. If I then use the first shortcode you posted I get a list of these two posts. I tried adding a third post, added a custom field named “services” and set the value to “test” – this post doesn’t show up in the list. It seems to be working just nice.
    Please try to make sure that the value is set exactly to “dentalimplants” without any whitespace because the code the in plugin relies on an exact match of the string in the custom field compared to the one you enter in the shortcode. If you want to you can change this comparison to something else; see line 204 in the plugin’s file.

  57. Hi Luke,
    simply adapt the output produced by the plugin to suit your needs. You can open the file list-posts-custom-field.php and starting on line 190 you can change the HTML code that’s generated.

  58. Hi… can we use this on our recipe site. We use the Cooking Lovers theme from Simon Bouchard. Unfortenately he doesnt give any support 🙁 Its a nice theme but we need to have a sort of an index of all the recipes.

    thx

  59. Hi Herman,
    sure, just use the plugin if it helps you creating an archive of all recipes on your site. It’s pretty easy to adapt the plugin’s output to your site’s needs so I’m sure it’ll help you with your index page.

  60. Hello

    Thank you for this!

    I want to sort a list alphabetically based on the last name

    I Have this: [lp field=last_name orderby= cfvalue:last_name order=desc ]

    The order does not come out alphabetical, is there anything I can do.

    Thank you!

  61. Thank you for the great plugin. I can see that its going to be making my life much easier.

    I’m using this shortcode:
    [lp field=title_alpha having=title_alpha,O]

    but I would like to output a couple of custom fields along with the title. I’m trying to edit list-custom-post-field.php, but am not so great with php and can’t seem to get the right syntax…

    I’m looking at:

    $rVal .= '<dt>'.$post->title."</dt>n".
             '<dd>'.$post->excerpt."</dd>n";

    I’m struggling to add: . get_field('year_written') . (?) next to the title. I’m sorry to bother you with something that is probably easy to do, if I knew better what I was doing!! Any help is appreciated.

    Thank you.

  62. Hi Denise,
    first off, I’m glad that the plugin is helping you on your website. If you want to insert the custom field year_written after the title the following code should do the trick:

    $year_written = get_post_meta($post->ID,
                                  'year_written',
                                  true);
    $rVal .= '<dt>'.$post->title.' '.$year_written."</dt>n".
             '<dd>'.$post->excerpt."</dd>n";

    You can of course add more custom fields as you see fit.

  63. Hello Christian,

    I am having some difficulty in using the “having” filter option. I am using WP_User Frontend to write posts and there are options xxx, yyy and zzz for custom field “Type”. This way, the custom field name becomes cf_Type. The author can select one or more options and so the value for custom fields cf_Type could be either xxx yyy or zzz, but also xxx,yyy xxx,zzz or yyy,zzz and even xxx,yyy,zzz. If I want to display all posts that have either xxx or xxx,yyy or xxx,zzz or xxx,yyy,zzz on a page, how do I have to write the shortcode?

    Thanks for your great plugin, Harry

  64. Amazing plugin! Thanks for sharing.
    I wonder if there is a way to build a list with the posts “having blah,123” OR “having blabla,345”.

    thanks!

  65. Thanks and congratulations for this plug-in!

    I’ve got an issue:

    [lp field=tipus having="ph,indiferent;alcada,de 3 a 7 metres"] and
    [lp field=tipus having="alcada,de 3 a 7 metres;ph,indiferent"] returns different results. Only the first one is correct, the second return all posts with tipus field. So I guess the order is important, but which order?

    Thanks…

  66. Hi Harry, Octavio, Nuria,
    @Harry: the most recent version of the plugin allows you to change the delimiter used to separate keys from values; I updated the docs above as well. This way the following should help you [lp field=cf_Type having="cf_Type;xxx,yyy" having_delim=";"] to change the default delimiter from “,” to “;” so it doesn’t interfere with the “,” in the custom field’s value.
    @Octavio: the plugin allows you to add as many custom field combinations to the having clause separated by a “|”. By default these fields are logically ORed; you can change it to AND if you want to. Example: [lp field=blah having="blah,123|blabla,345"].
    @Nuria: I updated the code which evaluated the having clause so please try to test this again. The order of the fields in the having clause should be irrelevant.

  67. This plugin is great!
    One question, as soon as i use split=”1″, the title changes to the field value. How can i set it so that the title remain the name of the post?

  68. I just released an updated version (1.9.4) that should fix this issue. If it does not fix your particular issue I will need some more time to check this out in more detail.

  69. 1.9.4 didn’t fix the issue. However, i got around it by simple replacing this around line 377:

    $title = ( $split == true ? $post->cfvalue : lpcf_get_custom_field($post->ID, $titlefields, $post->title) );

    with:

    $title = $post->title;

  70. Could this plugin be used to list Pages as well as Posts? It wasn’t clear to me from the documentation. I want to display a linked list of pages, like so: ‘Page title’, ‘Name of publication’, ‘Published date’ (i.e., not the Page’s creation date). Could that be done with the help of this plugin?

  71. Dear Johan,
    by default the plugin already uses posts and pages when searching items with the given fields. Regarding the way how you want to output the data you can change the HTML markup directly in the plugin’s PHP file starting on line 228; for special things you may need to know the WordPress API a bit though.

Comments are closed.