Skip to content

CustomFields property added to Post class #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions WordPressPCL/Client/Media.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ public async Task<IEnumerable<MediaItem>> GetAll(bool embed = false, bool useAut
return entities;
}

/// <summary>
/// Get All by Post ID
/// </summary>
/// <param name="ID">ID</param>
/// <param name="embed">Include embed info</param>
/// <param name="useAuth">Send request with authenication header</param>
/// <returns>List of all result</returns>
public async Task<IEnumerable<MediaItem>> GetAllByPostID(int ID, bool embed = false, bool useAuth = false)
{
return (await _httpHelper.GetRequest<IEnumerable<MediaItem>>($"{_defaultPath}{_methodPath}?parent={ID}", embed, useAuth).ConfigureAwait(false))?.ToList<MediaItem>();
}

/// <summary>
/// Get Entity by Id
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions WordPressPCL/Models/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ public class Post : Base
[JsonProperty("_embedded", DefaultValueHandling = DefaultValueHandling.Ignore)]
public Embedded Embedded { get; set; }

/// <summary>
/// Custom Fields. You have to add action to functions.php
/// </summary>
[JsonProperty("custom_fields", DefaultValueHandling = DefaultValueHandling.Ignore)]
public IDictionary<string,string[]> CustomFields { get; set; }

/// <summary>
/// Parameterless constructor
/// </summary>
Expand Down
16 changes: 15 additions & 1 deletion WordPressPCL/WordPressPCL.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.