Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
27 votes
4 answers
36k views

Manually set global $post vars with an ID, in order to use template tags

I have a function retrieving ID's of posts by very specific means. I need to be able to set the global $post in order to use functions like the_content(), which does not allow an ID as a parameter. ...
Mild Fuzz's user avatar
  • 4,190
2 votes
3 answers
31k views

How to Display Post View Count

I am trying to display post view counts. I've tried below function to display the post view count, but I'm getting same post view for all the post in loop. Not getting correct post view count. ...
Jack Torris's user avatar
1 vote
1 answer
56 views

Converting a dynamic piece of code using WordPress Loop into a static one using Post ID

<?php if (is_single()) { ?> <?php $imvi = get_post_meta(get_the_ID(), 't_puck_imvi', true); ?> <div class="class1" <?php if( 'none' === $imvi) { ?> style="display:none;" <?...
WordCent's user avatar
  • 1,877
1 vote
1 answer
50 views

Exclude category from

I am trying to exclude a category from <?php the_category(', ') ?> inside my loop. I came across the following code on CSS tricks that says would solve the problem. You add this to the functions:...
Ed Manson's user avatar
1 vote
0 answers
143 views

Shortcode not working with post counter

I am trying to make this a Wordpress shortcode, i mean the below code, but it doesn't seem to work , I included this in my function.php file, but it gave back multiple query result, as seen in the ...
Kazem Nocktrine's user avatar
0 votes
1 answer
25 views

Change all author links in Blog roll

I want all the author links on my blog page to go to a specific url ("/about") instead of the individual author pages. I know this can be done easily with JavaScript, but is there way to do it in ...
AJT's user avatar
  • 187
0 votes
1 answer
430 views

The_excerpt() doesn't parse <!--more--> - how to change that?

I'm using the_excerpt(); in blog.php file (post listing page) and it doesn't recognize <!--more--> if "Excerpt" field is empty and it grabs the beginning of the content as excerpt. This issue ...
Atadj's user avatar
  • 2,182
0 votes
2 answers
1k views

How to only publish posts with image in it

I use a standard loop in my index.php and that shows all the posts beeing posted. What i'm looking for is a code that only shows the posts that have image(s) in it. With other words: i only want to ...
Demilio's user avatar
  • 883
0 votes
1 answer
231 views

Add custom text automatically on each post

Suppose I have a post and it's the first paragraph is: "This a Pen. The color is red." I want to add a custom text like "2022" after "Pen" on first sentence, at the end ...
Mi Monir's user avatar
0 votes
1 answer
3k views

Get post format

I have loop and template for post if ( have_posts() ) : ?> <div class="container"> <div class="row"> <?php while ( have_posts() ) : the_post();?> ...
name name2's user avatar
0 votes
1 answer
107 views

Optimize CPT-function with a loop

I want to optimize my functions of a Custom Post Type (CPT). Now I have 10 meta boxes. For each box I have an extra function. The aim is to produce the 10 boxes in one function. I already tried the ...
user avatar
0 votes
0 answers
20 views

WordPress current post functions inside loop doesn't work anymore, are they incompatible with php 8.0?

I recently update php from 7.4 to 8.0 , since many functions doesn't work anymore ! I don't know if it's related but I have tried many solutions and none of them works. Using (get_...) , the_title, ...
imagIne's user avatar
  • 105
0 votes
0 answers
39 views

subtracting the current post form then whole loop, which is generating all CPT titles

<select class="title_select minimal"> <?php $loop = new WP_Query( array( 'post_type' => 'plugin', 'posts_per_page' => -1 ) ); ?> <?php ...
WordCent's user avatar
  • 1,877
0 votes
3 answers
2k views

Get post id outside loop : Notice: Trying to get property of non-object

I am trying to get the post id outside the loop in functions.php.but what error i am getting : Notice: Trying to get property of non-object in functions.php on line 549 function ...
hamidable's user avatar
0 votes
1 answer
51 views

Show post excerpt

I want to show several post excerpt, so I create function function my_excerpt($limit) { $excerpt = explode(' ', get_the_excerpt(), $limit); if (count($excerpt)>=$limit) { array_pop(...
name name2's user avatar
0 votes
1 answer
52 views

Show author bio box

I have post page with author info. But I want to show author box info only if author has description. this is what i tried to do: <?php if ( !empty(get_the_author_meta('description')) and !empty( ...
Pravayest Pravayest's user avatar
0 votes
2 answers
205 views

Getting rid of the blog page entirely

My goal is to not use a separate blog page but end up with a structure like this... http://domain.tld/page/comments/ I believe I can do this with the Cornerstone plugin ~ [ http://wordpress.org/...
Terence Milbourn's user avatar
-3 votes
2 answers
70 views

What function does the loop of displaying posts?

What is the function that does the echoing of posts like post title in h1 and then the post body and then the author name. I hope everyone understood what I'm trying to say else please ask in comments ...
Faiz Ahmed's user avatar