Tag Info

New answers tagged

0

To set the taxonomy post_tag to your custom post type, you need to set the taxonomies parameter in your arguments when registering your post type taxonomies (array) (optional) An array of registered taxonomies like category or post_tag that will be used with this post type. This can be used in lieu of calling register_taxonomy_for_object_type() ...


0

This is completely untested but I believe you would want something along these lines: <?php if( $loop->have_posts() ): while ( $loop->have_posts() ): $loop->the_post(); // Do stuff for results echo '<h2>' . the_title() . '</h2>'; // Check for tag if(has_tag($tag) { output HTML if true } endwhile; ...


1

This is being caused by core bug #33106 which was unfortunately introduced with the security fixes in 4.1.6 (and 4.2.3). New lines are erroneously being stripped from CDATA blocks in this situation. From the bug ticket: As of 4.2.3, depending on how a CDATA block is used, the stripping of new lines in this content may break when displayed on the front ...


3

This is an older question, but here's the answer for future generations: WordPress will check the styles against a whitelist and it will still strip the style attribute if none of the styles are safe. The default whitelist is: text-align margin color float border background background-color border-bottom border-bottom-color border-bottom-style ...


0

just to answer the second part, the syntax is: example.com/tag/blue?post_type[]=custom example.com/tag/blue?post_type[]=post or for multiple types: example.com/tag/blue?post_type[]=custom&post_type[]=post


1

I don't suspect that your tax_query is failing you, but actually your tag parameter is. single_tag_title() returns the name of the tag, not the slug. All tag and category queries are converted to a tax_query in the WP_Query class before being passed to the WP_Tax_Query class to build the relative string for the SQL query. Term names and slugs gets ...


0

I had a similar issue and was able to resolve the improper menu behavior by using the parent_file filter. $parent_file is set in the /wp-admin/edit-tags.php file, but it needs to be altered based on your use case. add_filter('parent_file', 'filter_subscriber_menu'); function filter_subscriber_menu($file) { $screen = get_current_screen(); if ...


2

Another very simple solution is to put this in your css file : .tagcloud a:before { content: "#"; font-color: #000; }


0

1) Filter wpautop() with ACF: function filter_ptags_on_images($content) { $content = preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content); return preg_replace('/<p>\s*(<iframe .*>*.<\/iframe>)\s*<\/p>/iU', '\1', $content); } add_filter('acf_the_content', ...


0

Finally, I was able to iterate through all 34,788 entries, but only by running the job in smaller batches based on the post date. Here is the final code that I used on a page template. Thank you @ialocin for setting me on the right path. The job is done, but there has to be a better, more automatic, way to iterate through the posts without setting post date ...


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 ...


1

You're right. It isn't a good structure. You are running three queries on the page-- the two you are creating plus the main query that is being completely ignored (plus ancillary queries). You are also clobbering the main query halfway through the page load when you overwrite $wp_query, which can cause unexpected and unpredictable results and difficulty ...


1

Did you try without $query-> in front of get_template_part() ?


0

Paste this code along side the code given by you I have not tested the code but it should do the trick... where you used this [blog1 items=1 cat=op-ed] replace this with this [blogtag items=1 tag=china] <?php $queried_object = get_queried_object(); $term = $queried_object->name; add_shortcode("blogtag", "blog_tag"); function blog_tag($atts, ...


0

Finally! just install this plugin https://wordpress.org/plugins/linkify-tags/ then insert this script to theme <?php c2c_linkify_tags('24, 9, 33'); ?> and done!


1

Use orderby=id You can simply sort the tags by term_id with the following GET request: /wp-admin/edit-tags.php?taxonomy=post_tag&orderby=id&order=desc and similar for other taxonomies. Why does this work? The orderby parameter is read through: if ( !empty( $_REQUEST['orderby'] ) ) $args['orderby'] = trim( wp_unslash( $_REQUEST['orderby'] ) ...


0

I did something similar in the past project and this is my solution. I hope this is what you want. <ul class="inline-list"> <?php query_posts('category_name=lain-lain'); if (have_posts()) : while (have_posts()) : the_post(); if ( get_the_tag_list() ) : ...


1

The easiest way to do this would be via SQL. Firstly take a backup of your database in case anything goes wrong. Then using phpMyAdmin or a similar SQL frontend run this SQL command: UPDATE wp_posts SET post_content = REPLACE(post_content, '<br>', ''); This will replace the tag <br> with nothing in all post content. If the tags are in ...


1

The quickest solution is export posts table from database, replace tags this using any code-editor. For posts content are simple text not serialized, in this way you can do all replacement in less than 10 minutes without any hassle. Then import the sql file in db. Thanks


2

Firstly, I would consider using one of WordPress' wp_kses-like functions, instead of PHP's strip_tags(). Secondly, query your posts with WP_Query or get_posts() with the fields parameter set to ids - seems like you don't need more than that. Thirdly, split up your loop into steps that are effective and manageable. Because 34000+ posts will likely reach the ...


5

You can hook onto pre_insert_term, check the taxonomy and whether or not the user has the specified role as follows: function disallow_insert_term($term, $taxonomy) { $user = wp_get_current_user(); if ( $taxonomy === 'post_tag' && in_array('somerole', $user->roles) ) { return new WP_Error( 'disallow_insert_term', ...



Top 50 recent answers are included