I have installed the plugin and put the shortcode [netsposts] in a text block of the multisite main home page but frontend the plugin shows nothing.
All the blog of the network are active and public.
I have the CMP plugin (Coming Soon Page) active in the entire network but the shortcode doesn’t work even after deactivating it.
Any help?
Thank you in advance
I am trying to get a list of posts (IDs only) asscociated with a custom taxonomy term, like this:
$args = array(
'fields' => 'ids',
'tax_query' => array(
array(
'taxonomy' => 'visibility',
'field' => 'slug',
'terms' => 'loggedin'
)
)
);
$posts = get_posts($args);
For some reason, this isn’t working – none of the posts returned are associated with the term in question (there are in fact several posts connected with the term in the database).
For context, I am using the call to ‘get_posts’ inside a ‘pre_get_comments’ callback aimed at intercepting a WP_Comment_Query. The comment query is made by a shortcode callback in a footer widget. The purpose of the shortcode is to display a list of the latest comments. My goal is to modify the query so that, if the user is not logged in, comments left on posts associated with the term ‘loggedin’ will be excluded from the list.
Here is the full code:
add_action('pre_get_comments', 'login_to_see_all_comments_in_footer_widget');
/**
* Users must be logged in to see comments on posts associated with the
* term 'loggedin' in the website footer widget.
*/
function login_to_see_all_comments_in_footer_widget($comment_query) {
if ($comment_query->is_main_query() || in_the_loop() || is_search()) {
return $comment_query;
}
$posts = null;
if (!is_user_logged_in()) {
// Get a list of post IDs
$args = array(
'fields' => 'ids',
'tax_query' => array(
array(
'taxonomy' => 'visibility',
'field' => 'slug',
'terms' => 'loggedin'
)
)
);
$posts = get_posts($args);
}
if (is_array($posts)) {
// Exclude comments associated with any of the post IDs
$comment_query->set('post__not_in', $posts);
}
return $comment_query;
}
I tried changing the values of ‘taxonomy’ and ‘terms’ in the call to ‘get_posts’ to see if that made any difference and, weirdly, it doesn’t – the exact same list of IDs are returned no matter what tax_query arguments are supplied. This tells me that there is probably some other code interfering with the results returned by get_posts(), but for the life of me I can’t figure out what this code is or where I can find it. Any help here would be much appreciated.
Cheers,
Jen
I have a subdomain install with WP Multi Network running. When I send a wp.getPosts request, via CURL, targeted at a subnetwork instead of the main ‘grandmother’ network, I get the posts living on the targeted ‘mother’ site (root of the subnetwork), but NOT any posts on any daughter subsite. So I got curious, and poked around with wp.getPost instead.
When I send a wp.getPost, to a daughter site (siteID=38, with a postID=35, real username, password, URL redacted) on a subnetwork, structured like so:
curl -d '<?xml version="1.0"?> <methodCall> <methodName>wp.getPost</methodName> <params> <param> <value>38</value> </param> <param> <value>username</value> </param> <param> <value>password</value> </param> <param> <value>35</value> </param> </params> </methodCall>' https://subdomain.url.com/xmlrpc.php
…I get back the error:
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><int>404</int></value>
</member>
<member>
<name>faultString</name>
<value><string>Invalid post ID.</string></value>
</member>
</struct>
</value>
</fault>
</methodResponse>
So it seems pretty clear to me that wp.getPosts doesn’t know how to find the subsite on the subnetwork, although the IDs are proper. Any insights?
https://www.ads-software.com/plugins/wp-multi-network/
]]>I have been reading the Codex’ get_posts section and a number of threads on this forum, but I am still incredibly lost.
I wish to insert a list of posts at the end of a page that has some other content above such list.
The questions are: (1) Do I set the parameters of get_posts (by X category, or post ID, etc) within that code, or when I call it later from the page? (2) If parameters are inserted within the code, how do I make different kinds of callings throughout the site? (2) How do I call the function from the page?
Thank you so very much in advance! I have spent a few days trying to understand how this works now and I am getting desperate
I have read get_posts
documentation, and two extensive forum discussions on the topic ([resolved] Display Posts for a specific Tag(s) on a Page?, [resolved] get_posts php code not working). But my problem is way more basic than what’s discussed in those.
I understand that PHP snippets won’t work inside a page, unless through an installed plugin.
Therefore:
1) WHAT code goes into WHAT .php file of the website?
2) WHAT code goes into the page itself.
3) Do I need to add a new snippet to the .php file (like in 1) for every different kind of query I may use in a page? (eg. tags, tags with exclusion, posts from an author, all sorts of queries)
For questions 1 and 2 I am not asking for a complete snippet, but a general idea. My understanding right now is that the
<?php $args = array(...);
$posts_array = get_posts( $args ); ?>
But I am not sure where this goes, and even less sure about what piece of code I shall then use in the page.
Thank you very much in advance!
]]>First time for me, please excuse my approximate english.
I have a website in local for a while and I can’t get to work one of the feature i wanted for it. The feature : get the category ordered by the date (of the last post in this category)
Let me explain, i have 5 main categories (say Local News, Arts, Music, Itw and Misc for exemple).
I have a loop in the index that retrieve the 2 last posts of each category but with 5 queries. (wich is…not great for now)
$args = array(
'cat' => 1273, //i change the cat id - this is the value that needs to be variable in my future query
'showposts' => 2,
'orderby' => 'date',
'order' => 'DESC',
'post__not_in' => $latest->posts //i have a slider and do not want my posts to be in double
);
$the_query = new WP_Query($args);
if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
etc
I want this order to change regarding the last post date of each category.
Lets say i had yesterday :
-Local News posts
-Arts posts
-Music posts
-Itw posts
-Misc posts
Today if i post in Music :
-Music posts
-Local News posts
-Arts posts
-Itw posts
-Misc posts
And tomorrow if i post in Misc :
-Misc posts
-Music posts
-Local News posts
-Arts posts
-Itw posts
And so on.
I hope my issue is understandable.
I search for a while now how to do it but it seems that nobody ever wanted to do it, or had any trouble while doing it at least !
Can anyone help me on this one ?
]]>They mention that if i use a archive page for my custom post type the filter wont work. just on the standard loop posts.
Basically i have a archive page for my custom post type where i return the results based on a certain taxonomy as this is dynamic based on the type of user logged in. But i need a search filter which can further filter down from there.
Any advise would be greatly appreciated. Can i pre get posts somehow so i can use the standard post loop?
Nick
]]><br />
<?php while ( have_posts() ) : the_post();</p>
<p> $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : ( get_query_var( 'page' ) ? get_query_var( 'page' ) : 1 );</p>
<p> $args = array(<br />
'paged' => $paged,<br />
'post_type' => 'post'<br />
);<br />
$all_posts = new WP_Query( $args );</p>
<p> ?></p>
<p> <div id="posts-container" class="clearfix"></p>
<p> <?php while ( $all_posts->have_posts() ) : $all_posts->the_post();</p>
<p> get_template_part( 'content' );</p>
<p> endwhile; ?></p>
<p> </div></p>
<p> <?php endwhile;</p>
<p>get_footer(); ?><br />
[bump moderated]
]]>I’d like to know how to get a post’s list from my custom taxonomy term in a select, maybe a code or something for the functions.php.
Thanks in advance
https://www.ads-software.com/plugins/contact-form-7/
]]>