How do I get the trackback count of a post in wordpress without writing an SQL query?

How do I get the trackback count of a post in wordpress without writing an SQL query? I tried searching Brave Search and I couldn't find anything helpful. To fetch the amount of comments a post has, get_comments_number() is the wordpress protocol function for it. But what if I want to fetch the amount of trackbacks a post has? And also, do I have to be inside "the loop" to do this? What if I'm outside the loop?
Category: Web

setup_postdata is not returning any values

I am using ACF to create a custom field called facilities. Within that field is a repeater field called facility. So each store has 'facilities', which contains a number of 'facility'. What I am doing is looping through each of my stores, getting the 'facilities', looping through each 'facility' within that, and displaying it. Here is a reference to the code I am using. My code: if( get_field( 'facilities' ) ): //print_r( get_field('facilities') ); $post_objects1 = get_field('facilities'); if( $post_objects1 ): …
Category: Web

How do I get tags linking to proper pages (/tag/sample-tag -> pages with that tag)

(Warning: WordPress newbie ahead...) I have a WP site with a bunch of posts, many of which have tags associated with them. However, clicks on links to such tags -- https://example.com/tag/sample-tag) -- don't produce the pages I would expect -- a collection of teasers for posts with that tag. I just get the "nothing" page -- "Nothing Found / It seems we can’t find what you’re looking for. Perhaps searching can help". I've dug through the database, and it looks …
Category: Web

How to check if I am inside the WP Theme Customizer preview?

I have some elements showing on the home page that I do not want to display in the Theme Customizer preview window. Is there a simple check in PHP that I can use for that ? For example: <img class="background" src="<?php echo $background ?>" <?php if(is_wpThemeCustomizer()) echo 'style="display:none"' ?>/> I could do it in javascript using the js file that is enqueued only in this case, but I would like to use PHP, or even better : CSS. Is it …
Category: Web

WP Method `get_theme_file_uri()` Doesn't Seem To Be Working Properly When Used In The Head Section Of A Site

I'm preloading a web font in the head section of a WP custom theme and when I use the full file path it doesn't throw an error and works OK. When I use the WP function get_theme_file_uri inside the href attribute, it loads the font but shows errors in the console and in Chrome's Lighthouse audit. The code I'm using in the href attribute is: href="<?php echo get_theme_file_uri('/fonts/alaska.ttf') ?> );" The file loads all OK but it questions whether I'm …
Category: Web

How to add Text before my Custom Term and hide it when empty

This is my code: <?php $terms = get_the_terms( $post->ID , 'this_is_custom' ); $links = []; foreach ( $terms as $term ) { $term_link = get_term_link( $term, 'this_is_custom' ); if( !is_wp_error( $term_link ) ) { $links[] = '<a href="' . $term_link . '">' . $term->name . '</a>'; } } echo implode(', ', $links); ?> The result are: Mango, Orange, Banana What it wants to achieve is: Tag: Mango, Orange, Banana How can I display the word "Tag: " and hide it when …
Category: Web

Making a Shortcode [NEXT] and [PREVIOUS] to place into specific posts for post navigation

I really need some help, I dont know where else to turn with this request. I'd like to add a shortcode to one of my posts. The template tags get_next_post() and get_previous will not work for me since I dont want post navigation on each post page and I want to control where it displays. In a DIV in an HTML structure I've created in a post. So what I need is to generate shortcodes from get_next_post() and get_previous_post()
Category: Web

Multisite get_home_url(); - Getting URL for current site

What would be the replacement for get_home_url() when using a multisite? For example, if I have one theme installed across several sites, and within the theme there are links that need to be specific to the current site. On my single install, using get_home_url(); would give me http://domain.com/, which was great, and if I moved the theme to a different domain, nothing would be affected. But when I'm using the same theme on a multisite, get_home_url(); gives me http://domain.com/ no …
Category: Web

How to show 'tags' in 'Wordpress Pages' [not Posts]

I have found a way to have the ‘category’ the page is recorded against to display at the top of the ‘page’ (this is not a post but a WordPress ‘page’). I would also like to display the ‘tags’ that have been recorded against this page but haven’t been able to find a way to achieve this – all the search results talk about are ‘removing tags from posts’ or getting ‘pages of tags’. These results make my ability to …
Category: Web

Child theme overirde template-tags in a theme built on underscores in inc/template-tags

I've read this post and I don't think this question is a duplicate because I have a specific question that has not been answered. My parent theme is using the following to require a template tag php file require get_template_directory() . '/inc/template-tags.php'; Is it possible to overide this in my child theme, If I place the same code in my functions.php and place the folder and file the same in my child theme folder I get a error saying Fatal …
Category: Web

add short code not working

I am new to wordpress, I am creating a plugin and for the short code, I am using the short code api. But when I insert this shortcode in my page, it displayes as it is, it does not display the required output. Can asny body tell me what i am doing wrong? Am I calling or creating the function on right place or not? Below is my code function show_review() { echo "this is a review form"; } add_shortcode('urp_review', …
Category: Web

How do I display a tag cloud under my post that only shows tags from that post?

I've be looking to add a tag cloud under my post that only shows tags pertaining to the post. The tags shown should be in a tag cloud format; the post tags that have more post tagged with it will be displayed in a bigger font. I've tried adding the following code under my posts: <?php wp_tag_cloud( array( 'smallest' => 8, // font size for the least used tag 'largest' => 22, // font size for the most used tag …
Category: Web

small problem in the article ()

WP 5.4 Theme masonic I try to show the numer of comments in each article it'as ok (see the picture) but on the next line, itshow () I don't know why !?!? the code in the file template-tags is: echo '<div class="entry-author vcard author fa fa-user"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></div>'; // Show number of comments echo '<div>(' . comments_number( '(0) ', '(1)', '(%)' ) . ')</div>';
Category: Web

Get_header raises an 500 internal server error

I am working on custom development in wordpress, my problem is the following every time I create a new template. Code /* Template Name: Citas Rolex*/ get_header(); echo "<h1>loren ipsum</h1>"; get_footer(); It gives me the following error in the user view In browser Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator to inform of the time the error occurred and of anything you might have …
Category: Web

Adding country tags automatically

I want to show country flags on post cards.My plan is showing flag icons with below code: <img src="/icons/<?php echo $tagName; ?>.png" /> However I dont know how can I add country tags to Wordpress.You know there are many many country on the world (If I am not wrong there are nearly 200 country based United Nations).Or maybe the country number of I will add as tag will be depend the icon set which I will find.So How can I …
Category: Web

how to limit and display tag?

Hi i need to show random 3 tags for a post. all my posts have been tagged with more than 10 tags, i need to display any 3 tags randomly. for eg: A sample post <a href="/tag1">Tag1</a> <a href="/tag2">Tag2</a> <a href="/tag3">Tag3</a> I am currently using <?PHP the_tags()?> to generate all tags how to restrict it to 3 randomly generated tags.
Category: Web

Editing Category Pages

I want to allow Search engine Robots to index my category pages, But it seems noindex,follow tags is auto add by my theme functions I want category pages to allow indexing while keeping noindex,follow for search and 404 pages Here's is part of them (functions.php) /*Add noindex to low value pages*/ function add_noindex_tags(){ # Get page number for paginated archives. $paged = intval( get_query_var( 'paged' ) ); # Add noindex tag to all archive, search and 404 pages. if( is_archive() …
Category: Web

Tag pages with regular editor

So, I am creating a website, review products and attach dozens of tags to them dependent on what the product entails. I have a custom review template for my products and based on what I tag the products as they will automatically show under the given tag-page. Now, my plan is to use the tag-pages to create content and rank with it. The problem is that the tag-editor is pretty limited in regards to its functionality, so I do not …
Category: Web

Pagination doesn't work in query post in tag template

In tag template I use the following query post: global $query_string; // required $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $posts = query_posts($query_string.'&posts_per_page=5&cat=-93&paged=' . $paged); if ( have_posts() ) : /* Start the Loop */ while ( have_posts() ) : the_post(); (content) endwhile; endif; wp_reset_query(); // reset the query the_posts_pagination( array( 'prev_text' => 'prev', 'next_text' => 'next' ) ); This is to have the post from current tag but exclude one category and show …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.