The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
1answer
206 views

Exclude custom function content from certain pages

I have added a small custom function to display a little author bio blurb at the bottom of each blog entry in my functions.php file inside the current theme that I am using. So far so good, it is ...
9
votes
3answers
7k views

Loading scripts only if a particular shortcode or widget is present

I needed a way to filter a page/posts content before it was loaded so I could add scripts to the header if a specific shortcode was present. After much searching I came across this on ...
20
votes
6answers
55k views

If is custom post type

I am looking for a way to test if a post is a custom post type. For example, in say the sidebar I can put code like this: if( is_single()) { //code here } I want code were I could do ...
5
votes
2answers
4k views

how to create a conditional content_width for a wordpress theme?

I'm trying to create a conditional statement for the content width in the functions.php of my theme. So some categories will have a content_width of 580, some will have 900. This will make the oEmbed ...
5
votes
7answers
4k views

wp_enqueue_script adding conditional statement not working

This is the code im using in my functions file: add_action('init', 'sort_out_jquery_pngfix_frontend'); function sort_out_jquery_pngfix_frontend() { global $wp_scripts; if(!is_admin()) { ...
1
vote
2answers
263 views

Conditionally load CSS/JS/PHP in wp-admin if using a mobile device

I'm looking for a way to conditionally load different scripts if the user is accessing the admin area from a mobile device. In my case I'm looking to restrict the user to just be able to make new ...
0
votes
2answers
136 views

Where do you add code in custom fuctions so it works on a specific page?

Thanks for replying but I still can't get it to work. Is anything wrong with this code? <?php class custom_loop extends thesis_custom_loop { function page() { if(is_page( ...
4
votes
1answer
3k views

How can I determine if a post has an image attachment?

As far as I know, there's not a simple function that will return true if a post has an attachment. With that in mind, what's the best way to determine if a post has an attachment (or even better, has ...
2
votes
2answers
3k views

wp enqueue style on specific page templates

I am in the process of a theme, I would like to add landing pages using page-templates. I cannot find anywhere that shows how to enqueue style or js for specific page templates. Any suggestions. Ex. ...
1
vote
2answers
460 views

Add default content to posts in a specific category?

Update / Question clarification: How could you modify the following code from this thread: Force category choice before creating new post? which offers a drop-down menu to choose a category BEFORE ...
1
vote
5answers
329 views

meta content on required pages

I need to post extra information on programs pages, so i have decided to use wordpress metabox but its showing on all pages. So is there any condition check so it could put meta box on those sub pages ...
0
votes
2answers
1k views

Conditional Statement - check if post has an attachment image

I'm working on a conditional statement (in a loop) that looks for a featured image then grabs a default image if there is none, which I have figured out. But, I also wanted a way to pull the first ...
2
votes
1answer
731 views

If function exists, and array is met, echo function?

I have a function like the following: <?php echo my_custom_function( array( 'category_url'=>'My Special Category' ) ); ?> It pulls data from the "My Special Category" and displays it. I ...
1
vote
2answers
2k views

How to conditionally enqueue a stylesheet only for a certain page(s)?

Before I get started, I want to acknowledge that there are some really good articles that are targeted at how to conditionally enqueue scripts based on page/post content. WordPress Plugin ...
1
vote
2answers
2k views

is_front_page, is_page('slug'), is_page(id) not working

None of the following are working to display conditional format in the sidebar when the current page is the home page: is_front_page, is_page('home'), is_page(id) I added an else clause which is ...
0
votes
2answers
383 views

Is there a PHP function that can match anything after the given URL, so my IF statement will work in each instance?

I have an IF statement shown below that runs one of 2 custom queries, based on the url. The problem I'm facing is if the url contains pagination such as /page/2/, my query breaks because the url isn't ...
0
votes
4answers
3k views

Why isn't is_page working when I put it in the functions.php file?

I have page called "Apple", the page's ID id 2533. In page.php file I have line: echo $bannerimg And this function in functions.php: if ( is_page( '2533' ) ) { // also tested with ...