New answers tagged

0

A good solution you could use is the Zapier platform. It has a specific recipe for Facebook posts to be posted to Wordpress (https://zapier.com/app/min/3821/start) To use this you'll need: A free Zapier account Install Jetpack Wordpress plugin Link Wordpress.com account to your WordPress install via Jetpack Link your Wordpress.com and Facebook Admin page ...


0

As per the discussion the_content is not a proper hook for filtering post titles while it filters the post content. wpautop() function is called with the_content so it adds the necessary paragraphs. To filter post titles use the_title instead, it won't add any markup tags by default: echo apply_filters('the_title', get_post_field('post_title', ...


2

"best" greatly depends on context. guid is probably (with some debate about it) the best way to uniquely identify a post, but not all import/export plugins leave it alone without changes. ID is a good identifier if you do not care about import and export. Slug is problematic because they might be changed by the user. The best thing to do if you need to ...


0

You could have saved yourself a ton of work and just used the Co-Authors Plus plugin. It has a guest author function. You do have to set them up, but there is no account/password for them, and they can have author pages. (I am not affiliated with them, just use it on several sites.)


-1

Have you looked into expire plugins ? https://wordpress.org/plugins/search.php?q=expire finally wordpress.org/plugins/post-expiring seems to have done the job.


0

You can use meta__value in orderby e.g. 'post_type' => 'tribe_events', 'posts_per_page' => -1, 'meta_query' => array( 'relation' => 'AND', 'event_title' => array( 'key' => 'post.title', ), 'event_id' => array( 'key' => 'EventVenueID', ), ), 'orderby' => 'event_title', Not tested but should work, this was introduced in ...


-1

OK I got it to work as follows. global $wpdb; $jlk = $wpdb->get_results("SELECT * FROM my_table"); foreach($jlk as $custompost) { $custompost_ids[] = $custompost->ID; } $args = array( 'post_type' => 'custompost', 'numberposts' => -1, 'post__in'=> $custompost_ids ); $result = get_posts($args);


0

My appologies. I was busy in the content-single.php. I have manged to sort this out by editing the single.php file in my child theme.


2

Here's one way by using wpdb::get_col() and fetch the id column: $pids = $wpdb->get_col( "SELECT id FROM my_table" ); We could then clean it by integer convert each id with: $pids = wp_parse_id_list( $pids ); Just note the different max value for intval(), depending on 32 or 64 bits systems.


2

post__in accept array of post IDs e.g. array(5, 4, 8, 9); Extending @bravokeyl comment. By default result is Object. As codex suggest you can change the output type of get_results() to these values. OBJECT - result will be output as a numerically indexed array of row objects. OBJECT_K - result will be output as an associative array of row objects, ...


2

You should be using get_the_terms(). wp_get_post_terms() queries the db to get post term info, where as get_the_terms() returns the post term objects directly from the post term cache and only queries the db if that info is not available. By default, all post's terms are cached by the query being executed. EDIT I cannot comment (crappy mobile), but there ...


1

Try this, with " tags on .= '<a href="'.get_permalink($id).'"><img src="'.$image['url'].'" /></a>';


0

You can add this below code in your function.php file function content_formatter($content){ $new_content = ''; $pattern_full = '{(\[raw\].*?\[/raw\])}is'; $pattern_contents = '{\[raw\](.*?)\[/raw\]}is'; $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE); foreach ($pieces as $piece) { if ...


0

Just realized, I was editing a different VERSION of the same post on the DB, hence that the changes were not reflected on the front end. Sorted now, thanks!


0

Your terminology is a little off. Search implies providing a search word of phrase and receiving matched when it is found in content. What you describe is commonly called filters or facets (sometimes faceted search). Implementing it would depend on your exact data architecture. You might use custom taxonomies, but really there aren't details in your ...


0

As an addition to your scripts I wrote the script which hides sidebars from the dropdown list (I couldn't find this anywhere). I made some reverse engineering of the original widgets.js Wordpress code to write this. The complete solution for allowing to drag & drop only to specified sidebars and to filter the dropdown list (you just need to put this in ...


2

I'm afraid I don't understand the question perfectly, so I apologize, but, $post_status = 'publish'; Wouldn't that do it? I am missing context though, are you building a query? Because to get all the posts by the current user, something like this would be needed: $args = array( "post_status" => "publish", "author" => get_current_user_id(), ...


0

You have some very confusing information in your post. Wordpress has 3 different types of pages to reference and from some of your URL structured references you might be adding a 4th. First Wordpress page is the "Page" which you can create from within the Wordpress dashboard. Second is the page in which it displays on (this really depends on your theme). ...


0

This question isn't really great, as it's well documented in many places, but the answer is: View the page source, and look in the "open" body tag. It should show something like: <body class="single single-post postid-29654 ... > This example the page id/post id is 29654


0

You need to add: 'supports' => array('title', 'editor','page-attributes','thumbnail') add this to your array after 'singular name' => 'pictures'. The thumbnail adds the featured image option to your post type. You can access the post type archive: yoursite/archive-pictures, this will use your themes archive.php file if it exists. Or you can ...


1

Hello maybe this can help, i use this kind of query to retrieve cpt query and display contents: <?php // querying Database $args = array( 'post_type' => 'Pictures', 'posts_per_page' => 6); $the_query = new WP_Query( $args ); ?> <?php // creating the loog if ( $the_query->have_posts() ) : while( ...


0

1) If you want default text in POST EDITOR, then use @Milo's answer. 2) If you want add default content in front-end output of post,then use this code (in functions.php): function add_before_content($content) { global $post; if ( 'page' == $post->post_type ) {return 'YOUR MESSAGE'.$content;} if ( 'post' == $post->post_type ) {return 'YOUR ...


0

WP-Members™ is a free membership management framework for WordPress® that restricts content to registered users. For reference please have a look


0

Make sure you call the global $post after the WordPress query. If you add an action to init or admin_init, the query isn't ready so there's nothing you can get out of the global $post variable. My advice would be to check the action reference from this page: http://codex.wordpress.org/Plugin_API/Action_Reference and choose one that works for you. For ...


1

If we use: $args = array( 'post_type' => 'custom_post_type', 'post_status' => 'publish', 'posts_per_page' => 9, 'meta_key' => 'pkg_id', 'orderby' => array( 'pkg_id' => 'ASC', 'rand' => 'DESC' ) ); then we get the order part as: ORDER BY wp_postmeta.meta_value ASC, RAND() DESC This seems to ...


5

There is no need to do an overrated amount of queries to accomplish this. you can still use only one query, the_posts filter and some PHP to sort your code as needed. I take that this is a custom query from what I read in your question, so we can do the following: First, we want to introduce a custom WP_Query parameter so that we can use that parameter ...


1

Not possible with a single query you would have to do 3 seperate query each one targeting the different "Package ID's" and ordering those queries as rand. $args1 = array( 'post_type' => 'custom_post_type', 'orderby' => 'rand', 'meta_query' => array( array( 'key' => 'pkg_id', 'value' => 1, // you ...


3

The specific function you are referring to is wpautop, which adds paragraphs & HTML linebreaks to already intermixed HTML & plain text. wpautop is part of a family of content-processing functions hooked to the_content, a filter applied to the post content after pulling from the database just before outputting. Taking a look at ...


0

Currently from your code I can see you are looping for post IDs from 1 to 1000 that isn't good. WordPress have lot of functions by which you can fetch post IDs, content and other information. One of them (according to your need) is get_pages() Check the documentation of get_pages() there are lot of examples. See the Example from above code:- $all_pages = ...


1

Looks like you have the Posts for Page plugin installed. I don't know where you have put that code you mention, but the page is generated by the shortcode, which says that output should be limited to the beauty category. You probably don't need to write code yourself. Read the manual of the plugin and change the shortcode accordingly.


2

Check out the WP_Query reference. For parameters. Date Parameters. $args = array( 'author' => 123 , 'date_query' => array( array( 'after' => 'January 1st, 2013', 'before' => array( 'year' => 2013, 'month' => 2, 'day' => 28, ...


0

You might want to load all the items on the page at the same time, and use jQuery to display however many at a time. So for example: By default you could load (to the DOM) and hide all of them, then load 4 at a time using jQuery's slice Here's an example for my videos, however you could also hide the previous 4 videos before loading the next 4 to simulate ...


0

Have a look at wp-cli and wp-api they could help you automate your process without you needing to know too much about wordpress.


0

Posts have a slug (that's the last part of the URL), and it must be distinct, even if posts are in different categories. If your only worry is SEO, don't worry. Google sees the URLs as distinct, and Google is used to dealing with URLs that have a suffix on them, and has no problems with it. The keywords in the URL are still the same and have the same ...


0

Try adding this to your functions.php - it will wrap the image in the div you want. function filter_image_send_to_editor($html, $id, $caption, $title, $align, $url, $size, $alt) { return '<div class="post-page-image" id="image-'.$id.'">'.$html.'</div>'; } add_filter('image_send_to_editor', 'filter_image_send_to_editor', 10, 8);


6

For the permanent solution, your SQL query is slightly off - you need: UPDATE db1357924680.wp_posts SET post_content = REPLACE( post_content, '[print_me]', '' ) WHERE post_content LIKE '%[print_me]%' MySQL replace example


4

There is an easier way to do this: add_filter( 'the_content', 'my_post_content_remove_shortcodes', 0 ); function my_post_content_remove_shortcodes( $content ) { /* Create an array of all the shortcode tags. */ $shortcode_tags = array( 'shortcode_1', 'shortcode_2', 'shortcode_3' ); /* Loop through the shortcodes and ...


1

Sticky posts are a pain in the butt, and is not properly implememnted IMHO. The source code clearly shows that sticky posts are only moved to the top on page one of the homepage (or any custom instance of WP_Query which emulates the homepage), sticky posts does not get removed from the paged pages. This, IMO, should be part of core, stickies should be moved ...


2

Fiddling with user roles would probably be the most robust solution, however a quick and dirty approach would be to set post meta-data to mark posts that should be hidden, then add a meta-query to post queries by using a pre_get_posts hook in order to restrict results to non-hidden posts for non-logged-in users. The following will limit all posts queried ...


1

http://wordpress.stackexchange.com/a/199997/86773 As the advice suggested here, switching my hook to "wp" instead of "init" allowed me to make the page comparison I wanted using is_page().


0

Have you tried get_the_ID function? Try this one to get the ID and after that you can get all the info you want. Does it help?


0

Florian's answer is probably your best bet because it gives the author the most control as to how the images are aligned so that would be my first answer. However, if you don't trust your authors to align the images themselves then we'll have to go another route. Unfortunately for the reasons you stated above, it doesn't look like we can use the :nth-child ...


0

I don't think Visual Composer is the problem. Have you installed a logging plugin? Open phpMyAdmin and simply delete them. They are likely a post type you dont use. You can use the following query DELETE FROM wp_posts WHERE wp_posts.post_type='suspected_posttype' Make sure you don't remove the posta that are used by your site. Check what post types you ...


0

Have the writer use the left/right align functionality built into the WordPress text editor. The editor adds alignleft or alignright classes to the aligned images. Way more info can be found in the WordPress codex.


0

You could do this with a simple script. IMPORTANT! - Backup your database before doing this & attempt at your own risk. Create a file called changeauthorcat.php in your main WordPress folder. <?php include( 'wp-config.php' ); global $wpdb; // Author username $username = 'exampleuser'; // New category slug $newCatSlug = 'examplecategory'; // find ...


0

You can get author posts id's ids =[] ids = SELECT id FROM `wp_posts` WHERE `post_author`=1 and then you can loop result new_category_id = 999 old_category_id = 111 for id in ids: UPDATE `wp_term_relationships` SET `term_taxonomy_id`=new_id WHERE `object_id`=id AND `term_taxonomy_id`=old_category_id or wp_set_post_categories( $post_ID, ...


0

Ok, I solved this with a nice function, now the only thing left to do is to find a way to update all of the blog posts. doing this by hand will be really bad here is the code that I used add_action( 'save_post', 'myplugin_save_postdata' ); function myplugin_save_postdata( $post_id ) { if ( 'page' == $_POST['post_type'] ) { if ( ! current_user_can( ...



Top 50 recent answers are included