Tag Info

New answers tagged

1

You can achive this using WP Query with meta_query argument as following. $args = array ( 'post_type' => array( 'post' ), // YOUR POST TYPE 'meta_query' => array( array( 'key' => 'country', 'value' => $your_country, // THE COUNTRY TO SEARCH 'compare' ...


0

This is the solution. I had the same problem with my Elegant Themes "Divi", but not other themes. I asked and in support forum the answer is in CSS: .stButton .stFb, .stButton .stTwbutton, .stButton .stMainServices { height: 28px !important; } Also, for the count bubble: .stHBubble { height: 22px !important; }


0

If those images have been inserted in your posts, deleting them from the Media Library will cause blank spaces with a broken image icon to appear in your posts. If you need/want to add alt text or change image file names, etc., better to do so directly in the Media Library than to delete existing images and then upload them again. If you do this, you will ...


0

There are two methods: The one mentioned in this question. And the one mentioned in this Codex page.


1

Don't forget that when you are adding a filter it will stay there for all subsequent request. I would suggest you remove the closure and do something like this: function x_example( $input ) { remove_filter( 'posts_where', 'x_example' ); return $input; } add_filter( 'posts_where', 'x_example' ); You will have to do the same thing for the posts_join ...


0

I'd figure, it mainly is not advised, because it is intended just to use it for built-in post types, just because you can use for custom post types it does not change anything on that intention. For example, if you use it and there are changes in WordPress that make that arguments use strictly available for built-in post types, then you are in trouble. ...


0

You need to change into the code, by default wordpress shows only post which are published. In your case you need to change the $args = array( 'post_status' => array( 'publish', 'draft') ); $query = new WP_Query( $args ); for more info you can look into this link: Another thing you can alter your current query using query post like ...


0

You can configure that in admin panel. Just go »Dashboard > Settings > Permalink« settings.


2

You can try using wp_insert_post_data for the task. Something like: function assign_new_post_to_specific_author( $data , $postarr ) { // Where author_ID is the ID of the author you want to assign the new post $data['post_author'] = author_ID; return $data; } add_filter( 'wp_insert_post_data', 'assign_new_post_to_specific_author', '99', 2 ); ...


1

try this $post_id = 11; $post = get_post($post_id); $slug = $post->post_name; <a href="<?php get_site_url(); ?>/abstract/<?php echo $slug; ?>" title="<?php the_title_attribute(); ?>">Abstract</a>


1

I think that by adding a delay you're not really fixing the issue, you're simply hiding it, until you grow and add more media and servers, so lsyncd will take longer, and you'll have to increase your delay every time. Also what about updating existing posts? People might add media items and update, or add more items to a gallery, you'll have to add delays ...


1

You can use publish_post action hook for notifying post author. function wpcs_author_notification( $post_id ) { $post = get_post( $post_id ); $author = get_userdata( $post->post_author ); $message = "Hi " . $author->display_name . ", Your post, " . $post->post_title . " has just been published at " . get_permalink( $post_id ); ...


0

i am not sure but this code is working for access two language posts. $posts = get_posts(array( 'post_type' => 'post', 'lang' => 'de,fr', // query German and French posts 'posts_per_page' => -1, 'oder' =>'ASC', 'orderby' =>'name' ...


1

In most of case, it would bee easier to use a Custom Post Type instead of creating a new table then it can solve you encoding problem because WordPress use unicode


0

lunacodes Please change Permalink in wordpress > Settings > Permalink Settings > SELECTED Post name.


1

Just run a normal tax_query and set the field parameter to slug in the query. I assume that you already have a way getting the array of slugs (Requires PHP5.4+) $args = [ 'post_type' => 'product', 'posts_per_page' => 12, 'tax_query' => [ [ 'taxonomy' => 'TAXONOMY_NAME', 'field' => ...


-1

Make sure your user has permission to publish. Some WordPress setups users such as authors do not have permission to publish posts directly, instead they can submit them for review for an admin to review and decide whether the post should be published or not. It is not a great idea to use an administrator user on daily basis so sometimes people create an ...


0

There's probably some better way of doing this, but thought i'd give it a go anyways :) - also got some of the answer from here Adding active class to first item <div class="container"> <div id="myCarousel" class="carousel slide" data-ride="carousel"> <!-- Wrapper for slides --> <div class="carousel-inner"> ...


-2

Wordpress themes such as MH News does this by default for all archive pages. Check this quotes website for reference


1

You have one or two issues here and possible future bugs that you might encounter term in your tax_query should be terms Be carefull with terms having dates as names and especially dates as slugs. This can cause issues and unexpected results if custom permalinks clash or if something falls into the template hierarchy for some reason. Never use the name ...


1

You are almost there. You just need to use wp_mail to send emails containing in your array. Here is how you can achieve that using save_post action hook. /** * To send email on updating your event post * * @param int $post_id The post ID. * @param post $post The post object. * @param bool $update Whether this is an existing post being updated or not. ...


1

Technically speaking, Woocommerce products are just another WordPress post object with a customized post type (which is product in this case). If you take a look at the create_product function inside class-wc-api-products.php, you'll see this line: // Attempts to create the new product $id = wp_insert_post( $new_product, true ); So the API ends up using ...


1

First of all, never use query_posts, use WP_Query to create additional queries. You can target specific post positions in the loop by using the built in current_post var of the query object. Here's an example using the post_class function: <?php $my_posts = new WP_Query( array( 'posts_per_page' => 3 ) ); if( $my_posts->have_posts() ): while( ...


0

I think the best option would be is to use your getPostViews() count and incorporate a system in there to append the trending term to the post once your counter hits 150. Here is our worksflow Get the post view count (which you are already doing) Compare the current count to the desired 150 Use wp_set_object_terms() to append the trending term to the ...


0

Simply if(!is_home() && !is_front_page()) add_action( 'thesis_hook_after_post', 'my_related_posts' ); will do that for you. It will not do the add_action() when we are at the home page or not any front page. If it doesn't work for you, may be you need to contact with the Thesis team.


0

1) You can create an account on AddThis. There's a Wordpress plugin for Addthis. 2) You can go to wordpress's plugins page and make a search for: "share", "social" or other words. There are plenty of plugins that you can use. Try for example this search. EDIT 3) You need to create custom fields. Search on wordpress.org/plugins for a module called ...


1

Wrong hook, because what gets passed to wp is the Current WordPress environment instance not The WP_Query instance like it is e.g. passed to loop_start. You could actually just do your check inside the function callback you hook to loop_start. Edit/note: You could just have done global $wp_query; inside the wp hook, it is actually the ...


0

this code is with in the loop of single.php , RIGHT? If so then give this code the try , it should work . Problem with your code seems that you are using showpost, rather you should be using posts_per_page Plus i see this fragments of code like `$test = ""; $test .= ',' . $tag->name; $test = substr($test, 1);` I don't seem to find its use. And ...


0

.wp-caption img, .wp-caption { width:auto !important; max-width:100% !important; height:auto !important; }


2

<?php $args = array( 'posts_per_page' => -1, 'post_type' => 'event', 'meta_query' => array( array( 'key' => 'event_date_end_timestamp', 'value' => time(), 'type' => 'numeric', 'compare' => '<' ) ) ); $programs = new WP_Query($args); ?> ...


1

do_shortcode([espro-slider id=21]) will process the shortcode and return the result. The Codex describes exactly this example: // Use shortcode in a PHP file (outside the post editor). echo do_shortcode( '[gallery]' ); You can often just call the callback directly also: function generic_shortcode_callback($atts,$content) { return "Yay! ".$content; } ...


0

This "scrippets for Wordpress" plugin worked well for me, writing screenplay content in fountain format: http://fountain.io/scrippets


1

As you have stated, rank is defined by a value in a custom field, so you would just need to get the value from the custom field and display it. You can try the following inside your loop global $post; // Just make sure the custom field name is correct $rank = get_post_meta( $post->ID, 'custom_field', true ); // Display the title and rank echo 'Rank ' ...


0

The problem You must remember to call the core function wp_reset_postdata(), after your while loop, to restore the global $post object. The comment form is relying on that object, that you override with your $queryPosts->the_post() call. Note that the extract() isn't recommended, check this answer by @toscho, for example. Removing comments To remove ...


0

I was missing quotes around my hidden attribute in my html form. The correct syntax is echo "<input name='mygroup' type='hidden' value=".$_POST['groupname'].">";


0

I found your post when I was looking to do the same thing. I don't know if I am too late for you, but maybe someone else will benefit. I have used a simple, free, effective plugin called 'Page Links To' It puts an extra box near the bottom of each editing page, and defaults to 'its normal Wordpress url'. But you can change it to redirect to a custom url, ...


1

Exist some WordPress function that retrieve the list of links (in my specific case only one) that are into a post? Check out the core wp_extract_urls() function: $urls = wp_extract_urls( $content ); that will extract urls from any given content. Example $content = 'Two test sites: <a href="http://foo.tld">Foo.tld</a> and ...


1

Create a template with a WP_Query to get posts with post type "post" then create a page and assign that template to that page. Templates: https://codex.wordpress.org/Templates Query by post type: https://codex.wordpress.org/Class_Reference/WP_Query#Type_Parameters


0

Overriding the default page breaking - with external content parts The page breaking takes place in the WP_Query::setup_postdata() method, when we call the_post() in the loop. The page parts are stored in the global $pages array and fetched with get_the_content() function. This happens all before the the_content filter is applied to the content. We can ...


0

I used the following in my child theme 'functions.php' to get posts by category name. You can also use category ID number but that didn't work for me. add_action('pre_get_posts', 'ad_filter_categories'); function ad_filter_categories($query) { if ($query->is_main_query() && is_home()) { $query->set('category_name','tips'); } }


1

There is nothing build-in to create the drop-down for you, so you have to do it yourself. To get the needed information you can use get_post_types() to get the post types you want, set the $args parameter accordingly. Additionally make sure to set the $ouput parameter to objects, because you need the data provided - it defaults to names and then you will ...


3

You can do this with pre_get_posts. This hook is called after the query variable object is created, but before the actual query is run. For excluding category id 32 and 39 from homepage, you can setup a function like this. function wpse_exclude_categories( $query ) { if ( is_admin() ) return; if ( $query->is_home() && ...


0

The quick and dirty answer would be something like this: function custom_admin_menu_links() { $user = wp_get_current_user(); if ( $user->has_cap( 'manage_options' ) ) { $type = 'book'; $page = get_page_by_title('home','object',$type); if (!empty($page)) { add_menu_page( 'Home', 'Home', 'edit_posts', ...


0

There is a function called get_page_by_title that accepts a post title and returns the ID of that post. You might even use it in conjunction with get_edit_post_link by passing the ID and retrieve the edit link. However, how can you be sure the post's title will never change? You could go a little further and add a settings page where you would map a ...


0

In wordpress for get random post you have a option with 'orderby' => 'rand'


0

Google "facebook linter". Choose the first search result which will be from official facebook website. Go there, enter your url, hit submit (or similar button for submission). Now come back to facebook profile, and post the url as an update. You will get the thumbnail.



Top 50 recent answers are included